Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA II Your hotdog stand buisness is globalizing, you need to develop a program

ID: 3902554 • Letter: J

Question

JAVA II

Your hotdog stand buisness is globalizing, you need to develop a program that tracks the actiies of all the hotdog stands.

You operate hotdog stands throughout the world.

You mst use the following package name for deeloping the java program:

package hotdogstandpackage;

There must be at least 2 java source code files that have the following names:

HotDogStandMainClass.java

Contains the public HotDogStandMainClass

Contains the HotDogStandClass

The program must create adn use at least three hot dog stand objects.

HotDogStandMainClass

Define a class named HotDogStandMainClass

The HotDogStandMainClass class must include the following methods

A main method

(the main method test driver must test all paths of the logic flow nd conditions of the program to validate program correctness. the main unit test driver must display information that indicates what is being tested with the test values being used and display a result output of the test. output must be readable. output doesnt have to say if test passed or failed, just the test values used for each test and the result.)

The class has the follwoign for private class member variables

static Hotdogs sold total for all stands & total number of hot dogs sold be all hot dog stands.

Define a class named HotDogStandClass

This class has the following for private member instance variables

Hotdog stand  Identification

Each stand should have a unique identification

? Stand Location A string that is the address of the stand which includes street, city and country. For examples: 12 Deepika Padukone Ci, Bangelore, Karnataka 67089, India 1038 West Nanjing Road, Westgate Mall, 8th Floor, Shanghai, Shanghai 200041, China

? Hot Dog Cost Cost cannot be negative, the cost must 0 or greater expressed in US currency with cents. Zero may be used for promotional sale days.

? Hotdogs Inventory Amount The lowest value the inventory can be is 0. Negative inventory amounts do not make sense.

? Hotdogs Sold Count How many hot dogs the stand has sold since the program was started

The HotDogStandClass Class must include the following methods

? A constructor

? Accessor (Getter) and Setter methods for all member instance variables

? HotDogsBuy method

? The method will be invoked each time someone (your main method test driver) wants to buy some hotdog(s). ? Has a parameter that indicates the requested amount of hotdogs to be bought

? If the inventory is 0, the method should display a message that there are no more hotdogs left to be sold. The method uses the amount of the hot dogs requested to:

? Increase the hog dogs total for all the stands by the parameter amount

? Increase tracked hot dogs sold

? Decrease the hot dog inventory

? This method should be intelligent regarding the inventory. The lowest value the inventory can be is 0. Negative inventory amounts does not make sense. If the buy amount is more than the inventory, the class should state the amount of hotdogs in inventory and state to retry a buy.

? stockInventory method that is used to add inventory

? Has a parameter that indicates the requested amount of hotdogs to be bought

Explanation / Answer

import java.io.*;
import java.util.*;

class HotDogStandClass{

    private String standId;
    private String location;
    private double cost;
    private int soldCount;
    private int inventoryAmt;

    public static int totalSoldCount = 0;
    public HotDogStandClass(String i, String l,double c, int inv){
         standId = i;
         location = l;
         cost = c;
         soldCount = 0;
         inventoryAmt = inv;
    }
    public void HotDogsBuy(int a){

        if (inventoryAmt == 0){
           System.out.println("No more hotdogs to sell ");
        }
        else if (a > inventoryAmt){
           System.out.println("Not enough hotdogs ");
        }
        else {
             soldCount = soldCount + a;
             totalSoldCount = totalSoldCount + a;
             inventoryAmt = inventoryAmt - a;
        }
    }
    public String getID(){
        return standId;
    }
    public String getLocation(){
        return location;
    }
    public double getCost(){
        return cost;
    }
    public int getSoldCount(){
        return soldCount;
    }
    public int getInventoryAmt(){
        return inventoryAmt;
    }
    public void setID(String a){
         standId = a;
    }
    public void setLocation(String a){
         location = a;
    }
    public void setCost(double a){
         cost = a;
    }
    public void setInventoryAmt(int a){
         inventoryAmt = a;
    }
   
   
}

public class HotDogStandMainClass{

    public static void main(String[] args){

         HotDogStandClass h1 = new HotDogStandClass("123","location 1",23.00,100);
         h1.HotDogsBuy(10);
         System.out.println("Sold Count:" + h1.getSoldCount());
    }
}