Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
Members have full access to the forums. Advertisements are removed for registered users.
How many FuelGuage class objects does the code create?
Should there only be one that all other classes share?
javaiscool (March 20th, 2013)
Most cars have only one per fuel tank.
This would be a great example of where to use the Singleton Design Pattern. If you know that your program is only ever going to need one instance of an object that's what you should do. Then any class can grab the instance from the class itself instead of having to pass it from one to another.
Writing code is your job, helping you fix and understand it is mine.
<-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!