• 0

JAVA API Implementation help


Question

Suppose there is a API called DVDPLAYER which has all the functions of the DVD player and simulates all the functions

and suppose I have a TestFile.java driver file, which when executed calls the methods from the DVDPLAYER class and if implemented correctly should have an output which is already known

how do I go about greating a JAVA file called DVDPLAYER.java from which TestFile.java calls methods from

is there any website or tutorial online which I can use? thanks

Link to comment
https://www.neowin.net/forum/topic/192378-java-api-implementation-help/
Share on other sites

13 answers to this question

Recommended Posts

  • 0

I'd like to help but I'm not quit sure of your question, according to what i understand from your question here is my suggestion (If i missunderstood you please correct me)

You want a DVDPLAYER.java file which contains the methods that TestFile.java is going to call?

Then create the DVDPLAYER.java file, include in it all the methods and then instantiate it in TestFile.java.

class TestFile{
     public static void main(String args[]){

                DVDPLAYER dvd = new DVDPLAYER();
                String examples = dvd.method();
    }
}

  • 0

well i already have a java file called testjava.java. and i have been provided with the DVD API and have to implement that API into making a class for the testjava.java file

I just want to know of a website or someone who can help me in it. i dont want the whole solution to it, just help in creating classes. thanks

  • 0
  OrangeSoul said:
well i already have a java file called testjava.java. and i have been provided with the DVD API and have to implement that API into making a class for the testjava.java file

I just want to know of a website or someone who can help me in it. i dont want the whole solution to it, just help in creating classes. thanks

Creating a class is simple.

import package.you.need.*;

public class DVDPLAYER 
/* extends something */  // used if you want to inherit from a class.  This class becomes of type "something", and can be used wherever class "something" is
/* implements something */  // used if you need to implement an interface.  An interface is a glue between two classes.
{
   public DVDPLAYER() {
      //anything you want to do when a new DVDPLAYER Object is made
   }
   public method1(TYPE args) {
      //TYPE can be any Class or primitive (int,float,etc)
      //fill in the body
   }
}

  • 0

Whoops, forgot to put that you need a return type in method1.

public TYPE method1(TYPE args) { }

TYPE can be void, int, float, char, String, or any Classes you have access to. If you don't want arguments, put (). You can have multiple arguments, such as method1(TYPE args1, TYPE args2, TYPE args3)

  • 0

Yeah i actually got confused with creating packages in java, like does anyone know how it works, i'm pretty sure your .java or .class files go into their folders, based on what you named the the package in your classes, but say within an IDE like Borland JBuilder. How exactly do you import the package? I've even added the classpath for that particular custom package i created.

  • 0

The IDE is telling this(default_tape_length, tape_Start);

is wrong, i want to implement both default and tapestart in the first constructor, how do i do this?

thanks

import java.util.Random;

    public class VCR
   
   {
     
      public final static int TAPE_START = 1;
  public final static int DEFAULT_TAPE_LENGTH = 180;
      public final static int DEFAULT_REVERSE_LENGTH = 1;
      public final static int DEFAULT_PLAY_DURATION = 30;
   
  private int sequenceLength;
  private int currentLength;

   
       public VCR()
      {
    this(DEFAULT_TAPE_LENGTH, TAPE_START);
  }  
  
       public VCR(int length)
      {
 	 if(length > 0)
 	 {
    sequenceLength = length;
 	 }
 	 else
 	 {
    sequenceLength = DEFAULT_TAPE_LENGTH;
 	 }
 	 currentLength = 1;
      }
   
       public boolean play() 
      {
 	 
      }
   
       public boolean play(int time)
      {
      }
   
   
       public boolean reverse()
      {
      }
   
       public boolean fastreverse(int jump)
      {
      }
   
       public void rewind()
      {
      }
   
       public void setlength(int length)
  {  
      }
   
       public int getLength()
      {
      }
   
       public int getCurrent()
      {
      }
                                                     
}

  • 0
  OrangeSoul said:
The IDE is telling this(default_tape_length, tape_Start);

is wrong, i want to implement both default and tapestart in the first constructor, how do i do this?

thanks

What do you mean you want to implement them? I don't see any constructor with 2 arguments, so that may be your problem. Just add another constructor.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Amazon Deals: Samsung Q990F Q900F Q800F 2025 Dolby Atmos soundbars with wireless subwoofers by Sayan Sen While separate AV receivers with hi-fi speakers are generally the preferred way to listed to music and watch movies/shows by audiophiles, the more general folks often prefer soundbars instead as they offer a capable all in one solution that is still plenty good. Currently Nakamichi is running discounts on multiple products from its Dragaon lineup as well as its Shockwafe model. If you are looking for more options to choose from Samsung has its Q-series products at lowest prices (purchase links towards the end of article). Q990F The flagship Q990F is an 11.1.4 system and the single subwoofer unit on it houses two opposite-facing 8-inch subwoofer drivers. Thus, together they move around the same amount of air as a single 12-inch subwoofer unit. In addition to increasing the bass by +3 dB, dual opposing drivers are also said to help reduce vibrations of the subwoofer cabinet by cancelling out the resonance. Samsung also says that the bass is "AI-optimized" but we are not sure if it actually helps or if it's just a buzz term here. Aside from the bass, dialogue in movies is the second most important thing, and Samsung claims great vocal clarity from its front speakers thanks to AVA (Active Voice Amplifier) Pro feature that is said to detect noise disturbances and amplify dialogue to make it more audible over such surrounding noises. Q900F Feature wise the Q900F is similar to the 990F model except it has fewer channels and it is a 7.1.2 setup. Finally the Q800F is a 5.1.2 system and it has a passive radiator instead of the additonal subwoofer driver unit. Get the Samsung Q series soundbars at the links below: Samsung Q990F 11.1.4ch Wireless Dolby Atmos, Q-Symphony, Game Mode Pro, Adaptive Sound (HW-Q990F, 2025): $1497.99 (Shipped and Sold by Amazon US) Samsung HW-Q900F 7.1.2 ch Wireless Dolby Atmos, Q-Symphony: $997.99 (Shipped and Sold by Amazon US) Samsung Q800F 5.1.2ch Q Series Soundbar + Subwoofer, Wireless Dolby Atmos, Q-Symphony, Game Mode Pro, Smart Integration (HW-Q800F, 2025): $697.99 (Shipped and Sold by Amazon US) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • They are shifting into AI now. Don't you see?
  • Recent Achievements

    • One Month Later
      Helen Shafer earned a badge
      One Month Later
    • One Month Later
      ambani880 earned a badge
      One Month Later
    • Week One Done
      ambani880 earned a badge
      Week One Done
    • First Post
      artistro08 earned a badge
      First Post
    • First Post
      paul29 earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      498
    2. 2
      ATLien_0
      223
    3. 3
      Michael Scrip
      196
    4. 4
      Xenon
      160
    5. 5
      +FloatingFatMan
      138
  • Tell a friend

    Love Neowin? Tell a friend!