Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes JAVA DISCREPANCY PROBLEM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JAVA DISCREPANCY PROBLEM" Watch "JAVA DISCREPANCY PROBLEM" New topic
Author

JAVA DISCREPANCY PROBLEM

Nathe Chan
Ranch Hand

Joined: Mar 12, 2009
Posts: 33
Can someone explain to me what the teacher is trying to get me to do?? I have problems understanding the question.

Here is the question.

Classes:::
You must create at least 2 classes to start off with. These classes are in "MovieInfo.java" which will be given to you.

And, while I have the MOVIEINFO.JAVA file open, I have been - all the time - left with utter confusion on what to do next. Can you guys please give me some hints and a hand out?

Here is the incomplete code. And, the teacher wants us to fill the rest of the lines in. I suppose that these concepts would have to do with inheritance.



Can someone please give me a HINT of what to do next. I DON'T NEED THE ANSWERS .. just a push off the ground.

I am supposed to GET AND SET THESE VARIABLES and then later display the movie data in JList Boxes.

Thanks,

- Nathe
Ryan Beckett
Ranch Hand

Joined: Feb 22, 2009
Posts: 192
Its hard to explain the concept so here whats one of the functions should look like. Its more of what to do rather than why.


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41613
    
  55
I'm guessing that the "which" parameter is used to differentiate between DVDs and BluRays, so it could be either a "D" or a "B" (for example).


Ping & DNS - my free Android networking tools app
Nathe Chan
Ranch Hand

Joined: Mar 12, 2009
Posts: 33
I still don't get it.
Chuck Mondi
Ranch Hand

Joined: Oct 14, 2008
Posts: 31
For the getter methods, it looks like you need to use if logic to determine what to return. It looks like the constructor initializes the title and quantities for each format (DVD and Blu-ray) that are in stock. So, if you look at the getMovieStock(char which) method, how will that method know whether you want the stock number for the DVD or Blu-ray of say The Dark Knight? It uses the 'char which' method parameter. So if it uses a method parameter you will need to have if logic that will determine what stock number to return for the format the user requests. Here is what I would do. Use this type of logic for the other methods. Assume that types of movies have chars 'D' for DVD and 'B' for Blu-ray.



As you can see, if movie is a DVD it will return the intMovieDVD amount, otherwise the movie is a Blu-ray and it will return the stock amount of intMovieBlueRay. As I said before you need to use similar logic for your other methods including the setters. If not, how will they know what variables to update?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38491
    
  23
Nathe Chan: please have a look at this FAQ: it is rude to write all UPPERCASE like that.
Nathe Chan
Ranch Hand

Joined: Mar 12, 2009
Posts: 33
Okay, I'll be aware of that next time. Sorry, I didn't know that it was a rude technique.

- Nathe
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38491
    
  23
Apologies accepted
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JAVA DISCREPANCY PROBLEM