fast food restaurant

fast food restaurant

I need to design a Java application to manage a drive-thru restaurant. There are two drive-thru windows to serve customers and a kitchen to prepare the ordered food. Use an random number generator to determine when a customer arrives. Assign the arrived customer to an available drive-thru window. If both widows are busy, put the customer in a waiting line.

Each customer may order any food from a menu that includes hamburgers, fries, drinks and cookies. The customer's order determines the time the kitchen takes to get the food ready. For example, hamburgers and fries may take longer than drinks and cookies. And, if the customer orders more of each, it will take longer too.

The program must display in each time unit the following information:

* Customers in the waiting line and/or new arrival
* The order being prepared and/or the order ready for each window

this is what i have so far:

import java.util.Random;
public class MainClass
{
    public static void main (String [ ] args)
    {
        Random gen = new Random ( );
        int capacity = 20;       //max # of customers in the waiting line
        Customer [ ] waitingLine = new Customer [capacity]; ;
        int  size = 0;          //actual # of customers in waiting
        DriveThruWindow window1 = new DriveThruWindow ();
        DriveThruWindow window2 = new DriveThruWindow ();
        Customer newArrival;
        while (true)
        {
            int whatHappens = gen.nextInt (100);
            if (whatHappens % 10  == 0)
            {
                newArrival = new Customer ();
                waitingLine[size++] = newArrival;
            }
            else  if (whatHappens == 0)
            {
               // closeTheRestaurant ( );
                break;
            }
            window1.update ();
            window2.update ();
            if (window1.isAvailable ( ))
            {
                if (size != 0)
                {
                    window1.startServingACustomer (waitingLine[0]);
                    for (int i = 0; i < size-1; i++)
                        waitingLine[i] = waitingLine[i+1];
                    size--;
                }
            }
            if (window2.isAvailable ( ))
            {
                if (size != 0)
                {
                    window2.startServingACustomer (waitingLine[0]);
                    for (int i = 0; i < size-1; i++)
                        waitingLine[i] = waitingLine[i+1];
                    size--;
                }
            }
            System.out.println ("\n\n**** customers waiting to place order......\n");
            for (int i = 0; i < size; i++)
                System.out.println (waitingLine[i].getTag ( ));
        }
        System.exit (0);
    }
}

public class Order
{
    private int orderNum;   //optional, not used now
    private Item [ ] items;
    private int numOfItems;
    private double total;
    private int totalTimeNeeded;


    public Order ( )
    {
        orderNum = 0;
        numOfItems = 0;
        total = 0;
        items = new Item [4];
        for (int i = 0; i < 4; i++)
            items[i] = new Item ( );
        totalTimeNeeded = 0;
    }

    public String toString ( )
    {
        String outString = "\n\n** order **";
        for (int i = 0; i < numOfItems; i++)
            outString += items[i];
        return outString;
    }

    public void setAnItem (String newName, double newUnitPrice,
            int newTimePerUnit, int newNum)
    {
        items[numOfItems].setItem(newName, newUnitPrice, newTimePerUnit,  newNum);
        total += items[numOfItems].getSubTotal( );
        totalTimeNeeded += items[numOfItems].getTimeNeeded ();
        numOfItems++;
    }


    public int getTotalTimeNeeded ( )
    {
        return totalTimeNeeded;
    }
}

public class Item
{
    private String name;
    private double unitPrice;
    private int timePerUnit;
    private int num;
    private double subTotal;
    private int timeNeeded;

    public Item ( )
    {
        name = "";
        unitPrice = 0;
        num = 0;
        subTotal = 0;
        timePerUnit = 0;
        timeNeeded = 0;
    }
    public Item (String newName, double newUnitPrice,
            int newTimePerUnit, int newNum)
    {
        name = newName;
        unitPrice = newUnitPrice;
        num = newNum;
        subTotal = unitPrice * num;
        timePerUnit = newTimePerUnit;
        timeNeeded = timePerUnit * num;
    }
    public void setItem (String newName, double newUnitPrice,
            int newTimePerUnit, int newNum)
    {
        name = newName;
        unitPrice = newUnitPrice;
        num = newNum;
        subTotal = unitPrice * num;
        timePerUnit = newTimePerUnit;
        timeNeeded = timePerUnit * num;
    }
    public String toString ( )
    {
        return "\n\nitem name: " + name + "\nnum of units: " +
                num + "\nunit price: " + unitPrice + "\nsubtotal: " +
                subTotal;
    }
    public double getSubTotal ( )
    {
        return subTotal;
    }
    public int getTimeNeeded ( )
    {
        return timeNeeded;
    }
}

import java.util.Random;
import java.util.Scanner;
public class Customer
{
    private String tag;
    private Order food;
    private int totalTime;

    public Customer ( )
    {
        setTag ();
        food = new Order ();
        totalTime = 0;
    }
    private void setTag ( )
    {   //4 upper case letters
        Random gen = new Random ();
        tag = "";
        for (int i = 0; i < 4; i++)
        {
            int code = gen.nextInt (26)+ 65;
            tag += (char) code;
        }
     }

     public void placeOrder (double dPrice, double fPrice, double hPrice, double cPrice,
                int dTime, int fTime, int hTime, int cTime)
    {
        Scanner inputDevice = new Scanner (System.in);
        System.out.println ("\n\ncustomer " + tag + ", please place your order......");

        for (int  i = 0; i < 4; i++)
        {
            System.out.print ("\n\n1: drinks: " + dPrice + "\n" +
                     "2: fries: " + fPrice + "\n" +
                     "3: hamburgers: " + hPrice + "\n" +
                     "4: cookies: " + cPrice + "\n" +
                     "Enter your choice. " + "\n" +
                                         "To end the order, enter 0: ");
            int foodChoice = inputDevice.nextInt ( );
            String foodName = "";
            double unitPrice = 0;
            int howMany = 0;
            int timePerUnit = 0;
            if (foodChoice == 0)
                break;
            else if (foodChoice == 1)
            {
                foodName = "drinks";
                unitPrice = dPrice;
                timePerUnit = dTime;
            }
            else if (foodChoice == 2)
            {
                foodName = "fries";
                unitPrice = fPrice;
                timePerUnit = fTime;

            }
            else if (foodChoice == 3)
            {
                foodName = "hamburgers";
                unitPrice = hPrice;
                timePerUnit = hTime;

            }
            else if (foodChoice == 4)
            {
                foodName = "cookies";
                unitPrice = cPrice;
                timePerUnit = cTime;

            }

            System.out.print ("how many: ");
            howMany = inputDevice.nextInt ( );
            food.setAnItem (foodName, unitPrice, timePerUnit, howMany);
        }

        System.out.println ("\n\ncustomer " + tag + " this is what you just ordered.....");
        System.out.println (food);
        totalTime = food.getTotalTimeNeeded ( );
        System.out.println ("your waiting time is " + totalTime);
    }
    public int getTotalTime ( )
    {
        return totalTime;
    }
    public String getTag ( )
    {
        return tag;
    }
}

public class DriveThruWindow
{
    private Customer whoIsBeingServed;
    private boolean available;

    private int clock;

    private final double DRINKS_PRICE = 1.5;
    private final double FRIES_PRICE = 1.7;
    private final double HAMBURGERS_PRICE = 2.5;
    private final double COOKIES_PRICE = 0.25;

    private final int DRINKS_TIME = 1;
    private final int FRIES_TIME = 2;
    private final int HAMBURGERS_TIME = 3;
    private final int COOKIES_TIME = 1;

        private double totalTime;
        private double placeOrder;
        private double output;
        private int timeLeftToFinish;
        private String tag;
    private Order food;


        public DriveThruWindow ( )
        {
            whoIsBeingServed = null;
            available = true;
            clock = 0;
        }

        public void startServingACustomer (Customer newCustomer)
        {
            whoIsBeingServed = newCustomer;
            System.out.println("welcome to Alyssa's fast food restaurant");
            totalTime = whoIsBeingServed.getTotalTime();
            //food = whoIsBeingServed.getOrder();
            //gasType = whoIsBeingServed.getGasType();
            //gasPurchased = whoIsBeingServed.getGasPurchased();
            //timeLeftToFinish = (int) (gasPurchased / HOSE_FLOW_RATE);
            System.out.println(timeLeftToFinish
                + " units of time needed for this transaction...");
            //Tag = whoIsBeingServed.getTag();
            available = false;
            whoIsBeingServed.placeOrder (DRINKS_PRICE, FRIES_PRICE,
                            HAMBURGERS_PRICE, COOKIES_PRICE,
                        DRINKS_TIME, FRIES_TIME,
                            HAMBURGERS_TIME, COOKIES_TIME);
            clock = whoIsBeingServed.getTotalTime ( );
        }

        public boolean isAvailable ( )
        {
            return available;
        }

        public void update ( )
        {
        if (clock != 0)
        {
            clock --;
            if (clock == 0)
            {
            available = true;
            System.out.println ("\n\ncustomer " + whoIsBeingServed.getTag ( ) +
                                           ", your order is ready. thank you");
            System.out.println ("\nnext customer.....");
            }
        }
        }
}
View Answers









Related Tutorials/Questions & Answers:
fast food restaurant
fast food restaurant  I need to design a Java application to manage a drive-thru restaurant. There are two drive-thru windows to serve customers and a kitchen to prepare the ordered food. Use an random number generator
ModuleNotFoundError: No module named 'restaurant'
ModuleNotFoundError: No module named 'restaurant'  Hi, My Python... 'restaurant' How to remove the ModuleNotFoundError: No module named 'restaurant' error? Thanks   Hi, In your python environment you
Advertisements
ModuleNotFoundError: No module named 'restaurant'
ModuleNotFoundError: No module named 'restaurant'  Hi, My Python... 'restaurant' How to remove the ModuleNotFoundError: No module named 'restaurant' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'food'
ModuleNotFoundError: No module named 'food'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'food' How to remove the ModuleNotFoundError: No module named 'food' error
ModuleNotFoundError: No module named 'food'
ModuleNotFoundError: No module named 'food'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'food' How to remove the ModuleNotFoundError: No module named 'food' error
system ordering food
restaurant order service using java.The system read from a file containing...) from the particular restaurant. The system then alerts the restaurant. Eventually,the restaurant prepares the ordered menu and delivers them to the customer
Cafe and Restaurant Website Design
Cafe and Restaurant Website Design We provide high quality Cafe and restaurant... and restaurant business. We are designing, developing, testing, uploading and maintaining websites for cafe and restaurant industry. A website is the virtual
ModuleNotFoundError: No module named 'food-python'
ModuleNotFoundError: No module named 'food-python'  Hi, My Python... 'food-python' How to remove the ModuleNotFoundError: No module named 'food-python' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 's3-dog-food'
ModuleNotFoundError: No module named 's3-dog-food'  Hi, My Python... 's3-dog-food' How to remove the ModuleNotFoundError: No module named 's3-dog-food' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ybc-food'
ModuleNotFoundError: No module named 'ybc-food'  Hi, My Python...-food' How to remove the ModuleNotFoundError: No module named 'ybc-food... to install padas library. You can install ybc-food python with following
ModuleNotFoundError: No module named 'food-python'
ModuleNotFoundError: No module named 'food-python'  Hi, My Python... 'food-python' How to remove the ModuleNotFoundError: No module named 'food-python' error? Thanks   Hi, In your python environment
Restaurant Search Applications ? Find New Places To Eat, Fast!
Restaurant Search Applications – Find New Places To Eat, Fast! Mobile... out at great places and are always up for trying something new then restaurant... of restaurants In days gone by, when you wanted to find a restaurant you would have had
ModuleNotFoundError: No module named 'odoo10-addon-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo10-addon-hotel-restaurant'  ...: No module named 'odoo10-addon-hotel-restaurant' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-hotel-restaurant' error
ModuleNotFoundError: No module named 'odoo10-addon-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo10-addon-hotel-restaurant'  ...: No module named 'odoo10-addon-hotel-restaurant' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-hotel-restaurant' error
ModuleNotFoundError: No module named 'odoo10-addon-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo10-addon-hotel-restaurant'  ...: No module named 'odoo10-addon-hotel-restaurant' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-hotel-restaurant' error
ModuleNotFoundError: No module named 'odoo10-addon-report-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo10-addon-report-hotel-restaurant...: ModuleNotFoundError: No module named 'odoo10-addon-report-hotel-restaurant' How...-restaurant' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo11-addon-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo11-addon-hotel-restaurant'  ...: No module named 'odoo11-addon-hotel-restaurant' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-hotel-restaurant' error
ModuleNotFoundError: No module named 'odoo11-addon-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo11-addon-hotel-restaurant'  ...: No module named 'odoo11-addon-hotel-restaurant' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-hotel-restaurant' error
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-restaurant...: ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-restaurant' How...-restaurant' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-restaurant...: ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-restaurant' How...-restaurant' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant'  ...: No module named 'odoo12-addon-hotel-restaurant' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant' error
ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant'  ...: No module named 'odoo12-addon-hotel-restaurant' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant' error
ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant'  ...: No module named 'odoo12-addon-hotel-restaurant' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant' error
ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant'
ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant'  ...: No module named 'odoo12-addon-hotel-restaurant' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hotel-restaurant' error
ModuleNotFoundError: No module named 'restaurant-service-client'
ModuleNotFoundError: No module named 'restaurant-service-client'  Hi...: No module named 'restaurant-service-client' How to remove the ModuleNotFoundError: No module named 'restaurant-service-client' error? Thanks  
ModuleNotFoundError: No module named 'restaurant-service-client'
ModuleNotFoundError: No module named 'restaurant-service-client'  Hi...: No module named 'restaurant-service-client' How to remove the ModuleNotFoundError: No module named 'restaurant-service-client' error? Thanks  
ModuleNotFoundError: No module named 'restaurant-service-flask'
ModuleNotFoundError: No module named 'restaurant-service-flask'  Hi...: No module named 'restaurant-service-flask' How to remove the ModuleNotFoundError: No module named 'restaurant-service-flask' error? Thanks  
ModuleNotFoundError: No module named 'food_network_wrapper'
ModuleNotFoundError: No module named 'food_network_wrapper'  Hi...: No module named 'food_network_wrapper' How to remove the ModuleNotFoundError: No module named 'food_network_wrapper' error? Thanks   Hi
ModuleNotFoundError: No module named 'food-trucks-boston'
ModuleNotFoundError: No module named 'food-trucks-boston'  Hi, My... named 'food-trucks-boston' How to remove the ModuleNotFoundError: No module named 'food-trucks-boston' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'matts-food-sim'
ModuleNotFoundError: No module named 'matts-food-sim'  Hi, My... named 'matts-food-sim' How to remove the ModuleNotFoundError: No module named 'matts-food-sim' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'seattle-food-truck'
ModuleNotFoundError: No module named 'seattle-food-truck'  Hi, My... named 'seattle-food-truck' How to remove the ModuleNotFoundError: No module named 'seattle-food-truck' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'food_network_wrapper'
ModuleNotFoundError: No module named 'food_network_wrapper'  Hi...: No module named 'food_network_wrapper' How to remove the ModuleNotFoundError: No module named 'food_network_wrapper' error? Thanks   Hi
ModuleNotFoundError: No module named 'food-trucks-boston'
ModuleNotFoundError: No module named 'food-trucks-boston'  Hi, My... named 'food-trucks-boston' How to remove the ModuleNotFoundError: No module named 'food-trucks-boston' error? Thanks   Hi, In your
Hire an iPhone Developer to develop restaurant application
Hire an iPhone Developer to develop restaurant application  Hi, My client is running a restaurant. Client is looking for developing an iPhone application. I want to hire an iPhone Developer to develop restaurant application
Information about Fun N Food Village Delhi
Fun N Food Village of Delhi The Fun N Food Village is an amusement park... the park. The Fun N Food Village was opened in 1993. It was built as a theme park... and the enjoyable Bumper Boat ride.ADS_TO_REPLACE_1 The Fun N Food Village
ModuleNotFoundError: No module named 'FAST'
ModuleNotFoundError: No module named 'FAST'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'FAST' How to remove the ModuleNotFoundError: No module named 'FAST' error
fast data science
fast data science  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: fast data science... "fast data science". Also tell me which is the good training courses
fast ms data science
fast ms data science  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: fast ms data... the topic "fast ms data science". Also tell me which is the good training
fast ai certification
fast ai certification  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: fast ai... the topic "fast ai certification". Also tell me which is the good
fast ai course
fast ai course  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: fast ai course Try...;fast ai course". Also tell me which is the good training courses
fast ai coursera
fast ai coursera  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: fast ai coursera Try... "fast ai coursera". Also tell me which is the good training courses
How fast is 2020 Growth?
How fast is 2020 Growth?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How fast... learn the topic "How fast is 2020 Growth?". Also tell me which
ModuleNotFoundError: No module named 'fast-arrow'
ModuleNotFoundError: No module named 'fast-arrow'  Hi, My Python... 'fast-arrow' How to remove the ModuleNotFoundError: No module named 'fast... have to install padas library. You can install fast-arrow python
ModuleNotFoundError: No module named 'fast-arrow'
ModuleNotFoundError: No module named 'fast-arrow'  Hi, My Python... 'fast-arrow' How to remove the ModuleNotFoundError: No module named 'fast... have to install padas library. You can install fast-arrow python
ModuleNotFoundError: No module named 'fast-atomic'
ModuleNotFoundError: No module named 'fast-atomic'  Hi, My Python... 'fast-atomic' How to remove the ModuleNotFoundError: No module named 'fast-atomic' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'fast-autocomplete'
ModuleNotFoundError: No module named 'fast-autocomplete'  Hi, My... named 'fast-autocomplete' How to remove the ModuleNotFoundError: No module named 'fast-autocomplete' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'fast-bert'
ModuleNotFoundError: No module named 'fast-bert'  Hi, My Python... 'fast-bert' How to remove the ModuleNotFoundError: No module named 'fast... have to install padas library. You can install fast-bert python with following
ModuleNotFoundError: No module named 'fast-bert'
ModuleNotFoundError: No module named 'fast-bert'  Hi, My Python... 'fast-bert' How to remove the ModuleNotFoundError: No module named 'fast... have to install padas library. You can install fast-bert python with following
ModuleNotFoundError: No module named 'fast-bert'
ModuleNotFoundError: No module named 'fast-bert'  Hi, My Python... 'fast-bert' How to remove the ModuleNotFoundError: No module named 'fast... have to install padas library. You can install fast-bert python with following
ModuleNotFoundError: No module named 'fast-carpenter'
ModuleNotFoundError: No module named 'fast-carpenter'  Hi, My... named 'fast-carpenter' How to remove the ModuleNotFoundError: No module named 'fast-carpenter' error? Thanks   Hi, In your python

Ads