Assignment13 - /* * * @author Dung Nguyen * Assignment:13 *...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/** * * @author Dung Nguyen * Assignment:13 * Due Date: November 25, 2009 * */ import java.util.Scanner; class Driver { public static void main(String args[]){ FoodCourt foodcourt = new FoodCourt(); foodcourt.operate(); } } class FoodCourt { private Restaurant restaurants[]; public FoodCourt(Restaurant restaurants[]){ this.restaurants = restaurants; } public FoodCourt(){ this.restaurants = new Restaurant[2]; this.restaurants[0]= new Subway("Subway"); this.restaurants[1]= new Cheeburger("Cheeburger"); } public void operate() { Scanner scanner = new Scanner(System.in); while(true) { printOptions(); System.out.print("Select the restaurant:"); int choice = scanner.nextInt(); if (choice ==0) { break; } { System.out.println("Welcome to " + restaurants[choice - 1].getName() + "!"); Food food = restaurants[choice - 1].prepareMeal(); } else System.out.println("Please choose a valid restaurant !"); } } public void printOptions() { for (int i = 0; i<restaurants.length;i++ )
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
System.out.println(" Enter " +(i+1) + " to choose " + restaurants[i].getName() + " restaurant") ; System.out.println(" Enter
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

Assignment13 - /* * * @author Dung Nguyen * Assignment:13 *...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online