Results 1 to 7 of 7
- 03-10-2011, 02:15 AM #1
Change Maker Startoff - Challenging
So my teacher decided to challenge us and gave us 1 week to make a graphical change maker. Basically what it will do is you will enter an amount to be paid, for example "$17.29".. and then you will enter an amount to pay with, for example "20.00"..
his requirements are a button for each of the types of bills "1,5,10,20,50,100" and coins "penny, nickel, dime, etc..", and then when you select a bill and coins to pay with, a picture of that bill and/or coin will pop up, and you can also be able to pay with more than one bill an or coin like "2 5's, 4 1's" and 3 quarters, and each time you press it the corresponding bill/coin will appear.. then there will be a confirm/pay button you hit to make the transaction.. and it will then say in a window box at the bottom saying "thank you for paying, your change is: x"... and when the change comes out it will have a picture of each bill/coin used to make the change..
Im baffled on how to approach this problem.. shoulda i use separate classes for each type of currency or should i use it all in one long class?
any help would be appreciated..
Thanks,
HbJgd
- 03-10-2011, 02:22 AM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
You can implement it however you wish (as long as it works as expected ;) ) . My advice would be to break the problem up...for example you need a GUI and an algorithm - break those elements up and work on each, in turn breaking each up further if needed. Trying to tackle it all at once can be overwhelming, and result in code that looks like spaghetti (aka code that is hard to debug and maintain).Im baffled on how to approach this problem.. shoulda i use separate classes for each type of currency or should i use it all in one long class?
- 03-10-2011, 02:48 AM #3
alright.. im thinking that making them all separate classes would be very inefficent because i would end up with 10+ different object classes.. but it could be much easier to code.. decisions decisions..
- 03-10-2011, 03:28 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Simpler to manipulate is almost always better. You can have 1 file with multiple classes if you want. The only real problem is that a currency type is generally constant so they should be designed a bit differently. (People should not be able to use constructors to change values) Show some code of the beginning, for now don't bother with the gui. Work on the classes and design the algorithms to work on the console.
Do some work, figure out as much as you can and then post code here when you get stuck and we can help you out.
Below is a basic outline of a 1 dollar bill to get you started
I gave you some things to use, and didn't design the exact methods and such for you but this is just a basic example to get your started.Java Code:class OneDollarBill{ //instance variables(value, image possibly?) //private constructor //static factory to get an instance //getters //setters are not needed(the image and value...or other instance variables, should not be able to be changed.) }Last edited by sunde887; 03-10-2011 at 03:32 AM.
- 03-10-2011, 04:42 AM #5
alright thanks.. im still in the planning stage.. im probably going to have 1 file with all the types of currency like you said, then make another file to actually do the change making.. the GUI is always the last thing i worry about, because it's my weakest point..
- 03-10-2011, 04:47 AM #6
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Ya, GUI's thankfully aren't that challenging, just a bit time consuming. If you get stuck or want guidance/advice on your code progress feel free to ask.
It's generally beneficial to break your project into lots of small parts that work together than have one massive gelatinous blob of code.
- 03-10-2011, 04:54 AM #7
Similar Threads
-
UML maker using SWT
By Ramandeep in forum SWT / JFaceReplies: 0Last Post: 03-09-2011, 11:35 AM -
Challenging error
By diwakardelhi in forum AWT / SwingReplies: 2Last Post: 11-15-2009, 09:40 PM -
How to draw in a JPanel using Netbeans 6.1 GUI maker
By Gatts79 in forum New To JavaReplies: 4Last Post: 08-28-2009, 06:50 PM -
challenging problems
By jayant3001 in forum JCreatorReplies: 24Last Post: 10-30-2008, 05:41 AM -
java api for reading adobe frame maker files
By venkatmatcha in forum Advanced JavaReplies: 2Last Post: 06-30-2008, 06:00 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks