Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java- How would I do this problem? I need to see it to understand it. The Green Community Theater produces plays each summer for ten

Java- How would I do this problem? I need to see it to understand it. The Green Community Theater produces plays each summer for ten weeks. Two different shows are performed. Each runs for five consecutive weeks on Saturday evening for a total of ten performances.

The goal of this programming assignment is develop an application that manages ticket sales for the Green Community Theater by implementing the perfect hashed data structure discussed in this chapter. The application should demonstrate that its four basic operation methods (insert, fetch, delete, and update) function properly. Your application should store nodes for tickets in the data structure. The Green Community Theater uses the following seating chart:

This theater has 4 sections with 25 rows of seats with 10 seats in each row within a section for a total of 1000 seats. The rows are labeled with the letters A through Y, with A being the first row in each section. Because there are 10 weeks there is a total of 10,000 ticket records that will be stored in the data structure.

Each ticket has a week number, a section number, a row number, a seat number, and the name of the ticket purchaser. It includes a ticket number generated from the above that must be unique. The relationship between ticket number and week number, section, row, and seat number is fixed and you should be able to determine the ticket number if given the rest of the information or provide the week, section, row, and seat if given the ticket number.

Here is one possible specification for a Ticket class:

Ticket

-

int ticketNumber

//May also be a String type

-

String purchaser

//Purchaser name

+

Ticket()

//Default constructor

+

Ticket(int, String )

//Constructor with ticket number and purchaser

+

Ticket(int, int, char, int, String )

//Constructorwith week, section, row, seat, purchaser

+

Ticket(Ticket)

//Copy constructor

+

void set(int )

//Set ticketNumber

+

void set(int, int, char, int )

//Set ticketNumber given week, section, row, seat

+

int getTicketNumber( )

//Returns ticketNumer

+

String getPurchaser( )

//Returns purchaser

+

void input( )

//Console input of Ticket object

+

int hashCode( )

//Return unique integer for each ticket

+

boolean equals(Object)

//Determines if two Tickets are equal

+

String toString()

//String output of all ticket info

+

static String ticketInfo( int)

//String output of all ticket info given ticket number

Note that this specification does not store week, section, row, and seat number in their own instance variables. That is because this information can be derived from the ticket number. If all those other variables were to be stored as instance variables there would be no need to store the ticket number since it could be readily generated from the other information. You are not required to use this specification, but you will have to write a Ticket class. You do not have to store unnecessary information in your Ticket class objects such as the price of the ticket and name of the show. But if you do, you must provide methods appropriate for handling all of the extra instance variables. Depending on how you design your ticket numbering scheme, you may have to write other methods such as a preprocessing method mentioned in the text.

It will be up to you to devise a ticket numbering encoding scheme. A ticket number does not have to be totally numeric, but can be a String that include numbers and characters. The important thing is that whatever design you choose for this, you must be able to map each ticket into a unique primary memory location (an array) within your PerfectHash structure. There can be no possible collisions, or you will not have the required PerfectHash structure. You must also ensure that ticket numbers are valid, that they all map to a location within the structure, and there are no run-time errors such as ArrayIndexOutOfBoundsException. You may choose to write validation code within your methods, as separate methods, or to have the validation done in the client code.

Besides your Ticket and PerfectHash classes, you will write a class named TicketApp with a main method that represents the application to keep track of ticket information. You will need to specify the size of your primary storage area here when instantiating your PerfectHash object. This is not subject to input by the user since you know there has to be at least 10,000 locations. Your application should use console input and present the user with the following menu options:

Enter: 1 to insert new ticket information (a sale is made),

2 to fetch and output ticket information by ticket number,

3 to fetch and output ticket information given week, section, row, and seat number,

4 to delete a ticket,

5 to update a tickets information,

6 to output information on all tickets sold, and

7 to exit the program.

This menu will be presented repeatedly until the user chooses option 7. Each of the options should call the methods that you wrote for your PerfectHash structure. Your should provide feedback for successful completion of the operation and an appropriate error message if an operation fails.

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions