aspose file tools*
The moose likes Beginning Java and the fly likes Candy Machine Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Candy Machine Question" Watch "Candy Machine Question" New topic
Author

Candy Machine Question

Chase Parsons
Greenhorn

Joined: May 06, 2014
Posts: 2
Hello,
As my last assignment in my beginner java course, I am tasked with building a candy machine. This machine will need to appropriately throw exceptions when needed. I have completed the majority of the project. I just need help writing my main method. I am basically stuck on a simple issue: how to assign my values. I thought about constructing an array, but I am hesitant on doing such. The only output needed is "Thank you for your purchase", but my program must "sell" the piece of candy to do so. So basically, if I do not throw an exception, my ONLY output will be that String.

Here is my main class:


And my Dispenser class:


And finally, CashRegister:


Thank you in advance.
Rico Felix
Ranch Hand

Joined: Mar 08, 2014
Posts: 288
    
    4

Chase Parsons wrote:The only output needed is "Thank you for your purchase", but my program must "sell" the piece of candy to do so. So basically, if I do not throw an exception, my ONLY output will be that String.


Basically all that needs to be done is some declarations and instantiations for each object in your application and pass the required two objects to the function call

Here is an illustration from which you can acquire ideas to meet your specific requirement:

Chase Parsons
Greenhorn

Joined: May 06, 2014
Posts: 2
Thank you!
I really drew a blank here as the semester is coming to a close. I was able to tweak some code and incorporate your suggestions in order to complete a successful project!
Rico Felix
Ranch Hand

Joined: Mar 08, 2014
Posts: 288
    
    4

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Candy Machine Question