CSCE 155

Homework Assignment 4: 

GUI Design in OO Fashion --- A Grocery Store

Assigned:  October 15, 2004

Due: Start of Class, October 27, 2004

 

Note: This assignment is to be completed individually - collaboration is strictly prohibited.

Points:  100 points (Programming: 85 points; Puzzle: 15 points)

 

Problem Description

 

In this assignment, you are required to design a GUI application using multiple classes. You will implement a simple Grocery Store. The interface for this assignment should allow the user to enter a customer’s name and his or her purchases in the store. For example, your program should record such information:

 

customer “Kim” purchases

1 unit of milk and 2 units of bagels on June 1, 2004

2 units of bread and 3 units of eggs on June 6, 2004

 

Your program needs to display the history of a customer’s purchases and compute the monthly total purchase amount.

 

You should design the system in an object-oriented fashion using multiple classes, each with well-defined functionalities that interact with the others to accomplish the requirements. The GUI application should perform the following tasks:

 

 

 

Figure 1

 

 

Figure 2

 

 

Figure 3

 

 

 

Figure 4

The system should contain five classes:

 

1.   GroceryStore: This class stores the merchandises and customers information. It includes an array (or a vector) of merchandises and an array (or a vector) of customers.  This class starts your application by displaying the welcome window to the user, and initializes all other classes.  Consider that the store has an unlimited supply of all its merchandises.  This is a GUI application class.

2.   Merchandise: This class has an item’s name, its unit price.   

3.   Customer:  This class has a customer’s name, an array of Purchase objects.

4.   Purchase:  This class has a purchase’s date, an array of Merchandise objects (as purchased items) and an array of integers, each integer recording the number of units purchased for a particular merchandise.

5.   PurchaseReport:  This class display the history of the purchase a custom made or compute the monthly total purchase.  This is a GUI application class.

 

In implementing GroceryStore class, the application should read the information of the merchandises from a file, called “MerchandiseInfo.txt”, which is in the following format:

 

Milk 3.34

Bagel 1.99

Bread 0.99

Icecream 2.50

Eggs 1.10

 

You can create your own item list, but remember to include at least 5 items. You can create your own item list, but remember to include at least 5 items.  You may assume that our test input file only has 1000 items.

 

Supplied Solution Components

 

None.

 

Submission Procedure

 

This assignment is due on October 27, 2004 at the start of class. Your grade will be reduced by 10% for each day it is late. It is recommended you read the grading policy and grading guidelines on the course website for a complete explanation of how the assignments will be graded. Remember, your program should follow good programming style, include plenty of comments, and perform all of the functionality outlined above.

After completing the assignment, you must “handin” the following files on-line:

1.      Source files: GroceryStore.java, Merchandise.java, Customer.java, Purchase.java, PurchaseReport.java and others

2.      Compiled files:  All the *.class files

3.      Readme file: README.TXT

4.      Data file: MerchandiseInfo.txt

 

Puzzle Assignment 4

 

Three soccer teams play against each other in a round robin.  The following table gives some information about the results.

 

Team

Played

Won

Lost

Tied

Goals For

Goals Against

A

2

2

 

 

 

1

B

2

 

 

1

2

4

C

2

 

 

 

3

7

 

There are missing numbers in the above table.  The actual numbers are actually (in bold): 

 

Team

Played

Won

Lost

Tied

Goals For

Goals Against

A

2

2

0

0

7

1

B

2

0

1

1

2

4

C

2

0

1

1

3

7

 

Your task is to write an algorithm for a program that will first take the following as input:

 

A 2 2 ? ? ? 1

B 2 ? ? 1 2 4

C 2 ? ? ? 3 7

 

And then the program will output the following:

 

A 2 2 0 0 7 1

B 2 0 1 1 2 4

C 2 0 1 1 3 7

 

Note only that your algorithm only has to provide a solution to the above, and does not have to be perfect for all possible combinations of numbers and missing numbers in a 3-team round robin. 

 

Is it possible for your algorithm to solve the following? If yes, shows the solution.  If no, then explain.

 

Team

Played

Won

Lost

Tied

Goals For

Goals Against

A

2

1

 

 

 

1

B

2

1

1

 

2

4

C

2

 

 

0

3

7

 

 

*  Based on Emmet 1995.