Create a method named justsold that increments the hotdogs

Assignment Help JAVA Programming
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();
}}

Reference no: EM13941193

Questions Cloud

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?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Determine the java application on web

Determine the Java application on Web and explain how program structure functions. Explain the application in as much detail as possible.

  Edit a java program to generate a better code

I need your help with this java program (That is what I have so far its not displaying the medal count)

  Create a separate class for the selected product

Create a separate class for the selected product that holds the item number, the name of the product, the department in which the product belongs, the number of units in stock, and the price of each unit. You must use the product and class name th..

  Specify, design, and implement a class

Specify, design, and implement a class that can be used in a program that simulates a combination lock. The lock has a circular knob with the numbers 0 through 39 marked on the edge, and it has a three-number combination, which we will call x,y,z.

  What is jsp and why do we need it?

What is JSP and why do we need it?

  Have an array of integers with user input instead of given

change the current code to have an array of integers with user input intead of given input from the main where it says int[] a=....; And also from a text file but the same numbers as what is given in main.

  Define java implementation to implement the requirements

Produce a Java implementation to implement the requirements of Question 1, that is, to perform the 32-bits two complement and 32-bit floating-point conversion of a given number.

  Object from question 1 manage its display

Write a Java statement to have the object from question 1 manage its display area by dividing it into 3 rows which have 4 columns each.

  Complete bst implementation

Complete BST implementation: - Write methods for ImOrder, PreOrder and PostOrder Traversals - Write min() method - Write Successor () method - Extra Credit Implement Binary Heapusmg An&Y Node implementation

  Build impressive piece of software to explore data sets

Assemble the GUI interactors and implement the NameSurferEntry class - build an impressive piece of software to explore interesting data

  Implement an inheritance hierarchy based on the following

Implement an inheritance hierarchy based on the following specifications for Account class, Checking Account class, and Savings Account class Methods: processDeposit ( ) - accepts a single double parameter containing the deposit amount. Updates the ..

  Writing a program that parses

The programming project involves writing a program that parses, using recursive descent, a GUI definition language defined in an input file and generates the GUI that it defines.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd