Reference no: EM13941193
You operate several hot dog stands distributed throughout town. Define a class named HotDogStand that has a member variable for the hot dog stand's ID number and a member 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 the number of hot dogs the stand has sold by one. The idea is that this method will be invoked each time the stand sells a hot dog so that we 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 hotdogs 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 hot dogs.
In this exercise, you should provide implementations for the following constructor and methods:
public HotDogStand()
public HotDogStand(int newID, int newNumSold)
public int getID()
public void setID(int newID)
public void justSold()
public int getNumSold()
public static int getTotalSold()
HINT:
getTotalSold() should be declared as a static method.
When a hot dog is sold, both the counter for the stand and the counter for the total number of hot dogs sold (at all stands) should be incremented.
/**
* This program defines a class for tracking hot dog sales. It tracks the
* stand's ID number, hot dogs sold at each stand, and hot dogs sold at
* all stands.
*/
public class HotDogStand {
/**
* Total hot dogs sold at all stands
*/
private static int totalSold = 0;
/**
* Number of hot dogs sold at this stand
*/
private int numSold = 0;
/**
* ID number for this stand
*/
private int id = 0;
// --------------------------------
// ----- ENTER YOUR CODE HERE -----
// --------------------------------
// --------------------------------
// --------- END USER CODE --------
// --------------------------------
public static void main(String[] args) {
HotDogStand s1 = new HotDogStand();
HotDogStand s2 = new HotDogStand(2, 0);
HotDogStand s3 = new HotDogStand(3, 0);
s1.setID(1);
s1.justSold();
s2.justSold();
s1.justSold();
System.out.println("Stand " + s1.getID() + " sold " + s1.getNumSold());
System.out.println("Stand " + s2.getID() + " sold " + s2.getNumSold());
System.out.println("Stand " + s3.getID() + " sold " + s3.getNumSold());
System.out.println("Total sold = " + HotDogStand.getTotalSold());
System.out.println();
s3.justSold();
s1.justSold();
System.out.println("Stand " + s1.getID() + " sold " + s1.getNumSold());
System.out.println("Stand " + s2.getID() + " sold " + s2.getNumSold());
System.out.println("Stand " + s3.getID() + " sold " + s3.getNumSold());
System.out.println("Total sold = " + HotDogStand.getTotalSold());
System.out.println();
}}
Financial accounting and management accounting
: Explain financial accounting and management accounting, highlighting the differences between the two strands of accounting Explain the sources of finance available to a business owner, making distinctions between internal and external sources, shor..
|
Evaluate efficiecy of strategy monopolistic market structure
: Identify three or more competitive strategies that Starbucks may use to maximize its profits in a monopolistic market. Evaluate the efficacy of these strategies in the monopolistic market structure
|
Calculate accounting rate of return on investment
: Part 1: Prepare a spreadsheet using Excel or a similar program in which you compute the following for each proposed location: Accounting rate of return on investment and Payback
|
Create a java application that displays the product number
: Create a product class that holds the item number, the name of the product, the numberof units in stock, and the price of each unit.
|
Create a method named justsold that increments the hotdogs
: Finally, add a static variable that tracks the total number of hotdogs sold by all hot dog stands and a static method that returns the value in this variable.
|
Calculate percent of sodium carbonate in impure sample
: How do you calculate the moles of sulfuric acid that remained in the solution after the reaction with the carbonate? calculate the moles of sulfuric acid that reacted with the carbonate
|
Ethical problems common to the workplace
: Focusing on social media and/or privacy research, discuss one or more ethical problems common to the workplace. Look at ethical decision making in relation to social and business outcomes.
|
Bunn operates a small family bakery
: It has recently moved into new premises and has invested in more advanced equipment, with the aim of making the baking process more automated.
|
Assuming that purchasing-power parity holds
: A McDonald’s Big Mac costs 2.44 yuan in China, but costs $4.20 in the United States. Assuming that purchasing-power parity (PPP) holds, how many Chinese yuan are required to purchase 1 U.S. dollar?
|