• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Using a method to return different string depending on situation

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So far there is a video class that contains a method to check in a movie


I'm creating a class customer that will keep count of videos and what videos are checked in and out
that belong to the customer. So I want the result to decrement/increment the video from the store
while simultaneously increment/decrement the video to the customers account. My question is
can I use the same method videoCheckIn from the video class and somehow display a different message
when the video is not available such as "this video is not on the customer's account" or will I have
to create a whole new method in my customer class almost exactly the same with a different s.o.p ("string")?
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could pass what ever message you want to be displayed as a method parameter.
 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I'll have to look up the syntax on how to write the code for that but I think I understand what your saying! This brings me to another question, if I use this same method from the video class will it keep a list of the movies the customer is checking out just
like it does for keeping track of the video's in the store from the infile data file and apply it to this customer's account with XXX id number?
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wasnt able to completely grasp your implementation, but have managed to let you know how to go about with your requirement. From what I see- I was thinking if the code structure would be as follows:


The above code is a very basic structure I could think of. You can improvise it. I am thinking if there's some flaw with the design in terms of- loose coupling and high cohesion.
 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I have, If I understand what your saying I would have to manipulate my videoCheckOut method to be able to print "The customer does not have this video" if the video is not in the customers list. On the other side of things the same method used for the list of video's in the store videoList.videoCheckout would come out with a message saying "The store does not have this video."

 
This guy is skipping without a rope. At least, that's what this tiny ad said:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic