lectures.htm
 

Assignment 4 and 5

Class name: StarbuckAssistant and StarbucksUtil
File name: StarbucksAssistant.java and StarbucksUtil.java
Type: Application

Due Date: 6/16/2003

NOTE: This assignment is worth 100pts

PLEASE UPLOAD YOUR ASSIGNMENT HERE


Description:
Starbucks, Inc. has hired you to create an application that will help their customers pre-order coffee for one week. In this test environment, Starbucks has elected to use a selected set of coffees for this application. The program will offer the customer their choice of a Cappuccino, or a Frappuccino, or a Latte'. All coffee comes in three sizes, "Tall", "Grande", or "Venti". The program will ask the customer to select a type of coffee and a size, then save both. Once the customer has set their coffee selection for each day of the week, the program will display their selections by day of the week.

Here is a sample of the program without errors:

Welcome to Starbucks! I'm your starbucks assistant and I will help you create your weekly starbucks coffee schedule.
To start week need to know what your coffee preferences are for each day of the week. Let's start with
Sunday:
Would you prefer a Latte', a Cappuccino, or a Frappucino?
Please select 1 for a Latte', 2 for a Cappuccino, or 3 for a Frappucino
1
What size coffee would you like?
Please select 1 for a Tall, 2 for a Grande, or 3 for Venti
1
Monday:
Would you prefer a Latte', a Cappuccino, or a Frappucino?
Please select 1 for a Latte', 2 for a Cappuccino, or 3 for a Frappucino
2
What size coffee would you like?
Please select 1 for a Tall, 2 for a Grande, or 3 for Venti
2
(Continues through the rest of the week)
The following coffee selections will be delivered to your home or office. Thank you for choosing Starbucks!
Sunday: Tall Latte'
Monday: Grande Cappuccino
Tuesday: Venti Frappuccino
Wednesday: Tall Latte'
Thursday: Grande Cappuccino
Friday: Venti Frappuccino
Saturday: Tall Latte'

Assumptions:
You may assume that all input is a number, either positive or negative.
You should use the famous EasyIn class to read the user's input

Requirements:
1) You must declare a two-dimensional array for the customer's coffee selection on each day of the week. The declaration is as follows:

String[][] coffeeSelection = new String[7][2];

For simplicity, I used three additional arrays, one to store the days of the week, one to store the type of coffee and one to store the sizes.

2) You must use the EasyIn class to handle user input.
3) All output to must come from the StarbucksUtil class. This class will contain utility methods that can be used by the StarbucksAssistant class. You are required to have two scheduleMessage() methods, and can choose what other methods you need. However, I have provided my class diagram if you want to use it as a guide. The class diagram for my StarbucksUtil is as follows:

Note: The overloaded method called scheduleMessage() and the signatures are as follows:

public static void scheduleMessage();
public static void scheduleMessage(String[] daysOfWeek, String[][] coffeeSelection);

The first method displays the message,
"The following coffee selections will be delivered to your home or office.
Thank you for choosing Starbucks!
"

and the second displays the user's coffee selection by day of the week.

Sunday: Tall Latte'
Monday: Grande Cappuccino
Tuesday: Venti Latte'
Wednesday: Tall Latte'
Thursday: Tall Latte'
Friday: Tall Latte'
Saturday: Tall Latte'

4) Your program must account for errors in the coffee selection and errors in the size selection. If a user makes an error, the application should display an error message and prompt the user for the information again, until a valid selection is made. ALL ERROR MESSAGE MUST START WITH "ERROR:", then an explanation of the problem. Remember, I said you can assume that all input as numbers. Below are examples of the two errors, one in coffee selection and one in size selection:

Coffee Selection Error:

Sunday:
Would you prefer a Latte', a Cappuccino, or a Frappucino?
Please select 1 for a Latte', 2 for a Cappuccino, or 3 for a Frappucino
5
ERROR: You have selected an invalid drink for Sunday
Would you prefer a Latte', a Cappuccino, or a Frappucino?
Please select 1 for a Latte', 2 for a Cappuccino, or 3 for a Frappucino

Size Selection Error:

What size coffee would you like?
Please select 1 for a Tall, 2 for a Grande, or 3 for Venti
23
ERROR: You have selected an invalid size for Sunday!
What size coffee would you like?
Please select 1 for a Tall, 2 for a Grande, or 3 for Venti

Your application should repeat this process until a valid selection has been made.

5)You are required to properly comment your code with JavaDoc comments. This means the class and all methods should have JavaDoc comments. StarbucksAssistant.java and StarbucksUtil.java only. The JavaDoc for the my application can be seen here.

Objectives:
* Be able to create Java application which runs directly on the system and NOT from a HTML file.
* Understand flow control structures. This application uses nested loops and nested if/else statements.
* Understand static methods and utility class definitions.
* Understand multi-dimensional arrays.

 

Home | Syllabus | Lectures | Assignments | Schedule | Coding Conventions | Links