Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CustomerLottery (90) Each year, Sleepy Hollow SuperStore holds a Manager for a Day lottery. A manager can participate by entering his/her name and ID number

  1. CustomerLottery (90)

Each year, Sleepy Hollow SuperStore holds a Manager for a Day lottery. A manager can participate by entering his/her name and ID number into a pool of candidates. The winner is selected randomly from all entries. Each customer is allowed one entry.

Customer class (10)

A Customer object holds a customers name as well as his/her ID number.

The name is a single word of type String.

The id is of type int.

The Customer class has the usual getter and setter methods. Further, Customer overrides the equals(Object o) method inherited from Object so that two students are equal if they have the same name and ID number. It also overrides toString().

StoreLottery class (60)

Implement a class StoreLottery, with the methods described below.

This class is instantiated with no parameters.

It has a an ArrayList of type Customer.

I suggest having a global Scanner for reading interactive input

void addCustomers

The addCustomers() method enters customers in the lottery and checks that there are no duplicate entries added to the list. To do this you should read in the customers from a file. You can read in the names from customerlist.txt in the Programs/Lesson 5/Homework tab, but your program should request the name of the file interactively.

Print out the names of any duplicates to the screen.

When all customers are read in,

Sort the list using the CustomerSortingComparator

Call printUnduplicatedList()

Call pickWinner() as described below.

void printUnduplicatedList()

Requests the name of an output file

Creates an Iterator prints out the unduplicated list to the output file using the Iterator

Then prints out the unduplicated list to the output file using an enhanced for

void pickWinner

The void pickWinner() uses the Random class to select one winner from among all customer entries (picked based on number of entries). It prints the name of the winner to the screen.

CustomerSortingComparator class (10)

Sorts the list of customers by name and if the names are the same sorts by ID

TestLottery class (10)

Includes a main method that creates a StoreLottery and then calls the addCustomers() method.

customerlist.txt

James 199 Jose 8900 Rosa 9054 Manfred 1234 Rosa 9054 Willie 9876 Juan 12345 Juan 78923 Hector 78923 Aaron 765 Lillith 6543 Eve 29 James 199 James 101 Jose 8900 Rosa 9054 Manfred 1234 Rosa 9054 Rosa 831 Robert 99

outnodup.txt

The Unduplicated Sorted List Output List Using Iterator Customer Aaron with ID 765 Customer Eve with ID 29 Customer Hector with ID 78923 Customer James with ID 101 Customer James with ID 199 Customer Jose with ID 8900 Customer Juan with ID 12345 Customer Juan with ID 78923 Customer Lillith with ID 6543 Customer Manfred with ID 1234 Customer Robert with ID 99 Customer Rosa with ID 831 Customer Rosa with ID 9054 Customer Willie with ID 9876 Output List Using Enhanced For Customer Aaron with ID 765 Customer Eve with ID 29 Customer Hector with ID 78923 Customer James with ID 101 Customer James with ID 199 Customer Jose with ID 8900 Customer Juan with ID 12345 Customer Juan with ID 78923 Customer Lillith with ID 6543 Customer Manfred with ID 1234 Customer Robert with ID 99 Customer Rosa with ID 831 Customer Rosa with ID 9054 Customer Willie with ID 9876

Sample Output to screen:

What is the name of your input file of names and IDs: customerlist.txt

The customer Rosa ID 9054 is a duplicate

The customer James ID 199 is a duplicate

The customer Jose ID 8900 is a duplicate

The customer Rosa ID 9054 is a duplicate

The customer Manfred ID 1234 is a duplicate

The customer Rosa ID 9054 is a duplicate

What is the name of your output file for the names: outnodup.txt

The winner and Manager for a Day is Customer Aaron with ID 765

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

Distinguish between poor and good positive and neutral messages.

Answered: 1 week ago

Question

=+j Explain the essential nature of repatriation.

Answered: 1 week ago