Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5.01) You operate several hot dog stands distributed throughout town. Define a class named HotDogStand that has an instance variable for the hot dog stands

5.01) You operate several hot dog stands distributed throughout town. Define a class named HotDogStand that has an instance variable for the hot dog stands ID number and an instance variable for how many hot dogs the stand has sold that day. Create a constructor that allows a user of the class to initialize both values. Also create a method named justSold that increments by one the number of hot dogs the stand has sold. The idea is that this method will be invoked each time the stand sells a hot dog so that you can track the total number of hot dogs sold by the stand. Add another method that returns the number of hot dogs sold. Finally, add a static variable that tracks the total number of hot dogs sold by all hot dog stands and a static method that returns the value in this variable. Write a main method to test your class with at least three hot dog stands that each sell a variety of HotDogs. Your main method should asks user to enter command. A command can be "sold", which in result would ask for cart number and increment its pointer. Another command can be "print", which will also asks for cart number and print how many hotdogs that cart sold. One command would be "print-all", that will result in printing how many HotDogs were sold by all carts. Call Staticmethod of HotDogStand for "print-all". Lastly, anything else will terminate the program.

Example:Entercommad:sold EnterCartNumber:0 Entercommad:sold EnterCartNumber:1 Entercommad:sold EnterCartNumber:2 Entercommad:print EnterCartNumber:0 Cartsold:1Entercommad:print EnterCartNumber:1 Cartsold:1Entercommad:print EnterCartNumber:2 Cartsold:1Entercommad:print-all Totalsold:3Entercommad:exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions