Browse over 20 million
homework answers & study documents

Computer Science

Java Assignment 9 - A Pizzeria

Type

Lab

Rating

Showing Page:
1/3
import java.util.Arrays;
import java.util.Scanner;
/**
* Created by e7006722 on 16/07/2014.
*/
public class Foothill {
public static void main(String args[])
{
Scanner console = new Scanner(System.in);
String choice = null;
int size = -1;
while(true)
{
System.out.print("Size of pizza (small, medium, large) or quit: ");
choice = console.next();
if(choice.startsWith("q") || choice.startsWith("Q"))
break;
PizzaOrder pizzaOrder = new PizzaOrder();
if(choice.startsWith("s") || choice.startsWith("S"))
pizzaOrder.setSize(0);
else if(choice.startsWith("m") || choice.startsWith("M"))
pizzaOrder.setSize(1);
else if(choice.startsWith("l") || choice.startsWith("L"))
pizzaOrder.setSize(2);
else
{
System.err.println("Invalid size entered");
continue;
}
while(true)
{
System.out.print("Current pizza: " +
pizzaOrder.stringizeSize());
if(!pizzaOrder.getToppings().isEmpty())
System.out.println("+" + pizzaOrder.getToppings());
System.out.println("Select an item by number (0 when done):");
for(int i=0; i<PizzaOrder.toppingsOffered.length; i++)
System.out.println((i+1) + ". " +
PizzaOrder.toppingsOffered[i]);
System.out.print("Selection? ");
int n = console.nextInt();
if(n==0)
{
System.out.println("Thanks you. ");
pizzaOrder.displayPizza();
break;
}
if(n>0 && n<=PizzaOrder.toppingsOffered.length)
pizzaOrder.addTopping(n-1);
else
{
System.err.println("Invalid selection.");
continue;
}
}
}
}

Sign up to view the full document!

lock_open Sign Up

Sign up to view the full document!

lock_open Sign Up

Sign up to view the full document!

lock_open Sign Up

Anonymous
Had to paraphrase some of the content but overall, really useful material.

Anonymous
Thanks, good work

Anonymous
Heard about Studypool for a while and finally tried it. Glad I did caus this was really helpful.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4