Question
Java Code ONLY NEED Method Public int [] getSizeCount() Already have the reset just double check if there is any mistakes no need for any
Java Code
ONLY NEED Method Public int [] getSizeCount()
Already have the reset just double check if there is any mistakes
no need for any input or output just need the method to do the things listed in the description
Have this for coffee class
class Coffee{ public static final int TALL = 1; public static final int GRANDE = 2; public static final int VENTI = 3;
private String name; private int size; private double cost; private int timeToMake;
public Coffee(String name, int size, double cost, int timeToMake) { this.name = name; this.size = size; this.cost = cost; this.timeToMake = timeToMake; }
public String getName() { return name; }
public int getSize() { return size; }
public double getCost() { return cost; }
public int getTimeToMake() { return timeToMake; }
@Override public boolean equals(Object obj) { return super.equals(obj); }
public String toString(){ return "Name= " + this.name + ", Size= " + this.size + ", Cost= " + this.cost + ", TimeToMake= " + this.timeToMake; } }
Have this for CoffeeHouse class
import java.util.*;
public class CoffeeHouse { Queue
Coffee c1 = new Coffee("Tom",2,6,5); Coffee c2 = new Coffee("Harry", 1 , 3.5 , 10); Coffee c3 = new Coffee("Mark" , 5 , 15 , 15); Coffee c4 = new Coffee("Sophia" , 3 , 3 , 3);
CoffeeHouse ch = new CoffeeHouse();
//taking order ch.takeOrder(c1); ch.takeOrder(c2); ch.takeOrder(c3); ch.takeOrder(c4);
Coffee t1 = ch.serveOrder(); System.out.println(t1.toString());
double revenue = ch.getPotentialRevenue(); System.out.println("Revenue -- " + revenue);
int time = ch.timeToMakeCoffeeOrders(); System.out.println("Time -- " + time);
int numOfOrder = ch.numOfOrders(); System.out.println("Num of orders " + numOfOrder);
Coffee t2 = ch.viewNextOrder(); System.out.println(t2.toString());
int getNumOrder = ch.getNumOrders(); System.out.println("Get Num of orders " + getNumOrder);
double revenueCollected = ch.getRevenue(); System.out.println("Collected revenue " + revenueCollected); }
public boolean takeOrder(Coffee c){ if(c!=null) { q.add(c); totalRevenue = totalRevenue + c.getCost(); totalTime = totalTime + c.getTimeToMake(); return true; } return false; }
public Coffee serveOrder(){ totalRevenue = totalRevenue - q.peek().getCost(); totalTime = totalTime - q.peek().getTimeToMake(); revenueCollected = revenueCollected + q.peek().getCost(); return q.remove(); }
public double getPotentialRevenue(){ return totalRevenue; }
public int timeToMakeCoffeeOrders(){ return totalTime; }
public int numOfOrders(){ return q.size(); }
public Coffee viewNextOrder(){ return q.peek(); }
public int getNumOrders(){ return q.size(); }
public double getRevenue(){ return revenueCollected; } }
Description: We have been hired by a local coffee house to build them a simple order placement system Since we have begun discussing "queues" as a tool, this presents us with a perfect opportunity to utilize them in our program Packaging: Fully qualified class names are listed below: (Note: the bold is the class itselfj) edu.ben.labs.lab4.Coffee edu.ben.labs.lab4.CoffeeHouse Program Requirements: 1. Create a class called "Coffee" a. This class should have AT LEAST the following class variables: public static final int TALL-1; public static final int GRANDE-2; public static final int VENTI3 private String name; private int size; private double cost; private int timeToMake; public Coffee(String name, int size, double cost, int timeToMake) b. Make sure to override both equals and toString in this class 2. Implement the following methods in a class called "CoffeeHouse" *Takes a coffee object and adds it to the next location in the "queue" *@param c *@return true if coffee was added to queue, false if param c is null not null coffee object public boolean takeOrder(Coffee c) *Returns an array containing the size counts of the coffee orders. *Location 0 is the count of the smallest size, location 1 is the count of the medium size, and location 2 is the count of the largest size *@return array containing the number of coffee orders by size public int[] getSizeCount() Description: We have been hired by a local coffee house to build them a simple order placement system Since we have begun discussing "queues" as a tool, this presents us with a perfect opportunity to utilize them in our program Packaging: Fully qualified class names are listed below: (Note: the bold is the class itselfj) edu.ben.labs.lab4.Coffee edu.ben.labs.lab4.CoffeeHouse Program Requirements: 1. Create a class called "Coffee" a. This class should have AT LEAST the following class variables: public static final int TALL-1; public static final int GRANDE-2; public static final int VENTI3 private String name; private int size; private double cost; private int timeToMake; public Coffee(String name, int size, double cost, int timeToMake) b. Make sure to override both equals and toString in this class 2. Implement the following methods in a class called "CoffeeHouse" *Takes a coffee object and adds it to the next location in the "queue" *@param c *@return true if coffee was added to queue, false if param c is null not null coffee object public boolean takeOrder(Coffee c) *Returns an array containing the size counts of the coffee orders. *Location 0 is the count of the smallest size, location 1 is the count of the medium size, and location 2 is the count of the largest size *@return array containing the number of coffee orders by size public int[] getSizeCount()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started