tity; private int capacity; private int seatsTaken;   public DesertEvent(String eventName, String eve

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
public class DesertEvent {
private static int eventCount = 0;
private String barCode;
private String location;
private String eventName;
private String eventType;
private int quantity;
private int capacity;
private int seatsTaken;
 
public DesertEvent(String eventName, String eventType) {
this(eventName, eventType, 0);
calcMaximumSeats(eventType);
generateBarCode();
}
 
public DesertEvent(String eventName, String eventType, int capacity) {
this.eventName = eventName;
this.eventType = eventType;
this.capacity = capacity;
generateBarCode();
eventCount++;
}
 
public String getBarCode() {
return barCode;
}
 
public String getLocation() {
return location;
}
 
public String getEventName() {
return eventName;
}
 
public String getEventType() {
return eventType;
}
 
public int getQuantity() {
return quantity;
}
 
public void setQuantity(int quantity) {
this.quantity = quantity;
}
 
public int getCapacity() {
return capacity;
}
 
public void setCapacity(int capacity) {
this.capacity = capacity;
}
 
public int getSeatsTaken() {
return seatsTaken;
}
 
public void setSeatsTaken(int seatsTaken) {
this.seatsTaken = seatsTaken;
}
 
public int getAvailableSeats() {
return capacity - seatsTaken;
}
 
private void calcMaximumSeats(String eventType) {
switch (eventType) {
case "Workshop":
location = "Library Meeting Room 28";
capacity = 30;
break;
case "Seminar":
location = "High Rise 151";
capacity = 100;
break;
case "Career fair":
location = "Fitch Hall 28";
capacity = 100000000;
break;
default:
break;
}
}
 
private void generateBarCode() {
Random rand = new Random();
int randNum = rand.nextInt(90000) + 10000;
barCode = eventType.substring(0, 3) + "-" + randNum + "-" + eventCount;
}
 
public boolean bookSeats(int numOfSeats) {
if (numOfSeats <= getAvailableSeats()) {
seatsTaken += numOfSeats;
return true;
} else {
return false;
}
}
 
public String toString() {
return "Event Name: " + eventName + "\nEvent Type: " + eventType +
"\nLocation: " + location + "\nQuantity: " + quantity +
"\nCapacity: " + capacity + "\nSeats Taken: " + seatsTaken +
"\nBar Code: " + barCode;
}
}
 
How would I implement the Driver class?

The Driver class (TestDesertEvent)

four event objects, each an object of the class type

DesertEvents, in the main method:

DesertEvent event1 = new DesertEvent (“Success in Life ”,

“Workshop”);

DesertEvent event2 = new DesertEvent (“Seminar Prep”,

“Seminar”, 50);

DesertEvent event2 = new DesertEvent (“Working with others”,

“Workshop”, 10);

DesertEvent event3 = new DesertEvent (“career fair”, “Career

fair”)

 

 Then, the program should display a welcome message and the following menu to

choose from:

Please choose one of the following:

L – list all available events

IR – individual registration

GR – group registration

Q – quit

The menu should be displayed by calling a static method inside DesertEvent class

called displayMenu(). The menu should keep repeating until the user chooses to quit. See

sample outputs below:

 

Sample output (user input in bold):

Welcome to DesertEvents page!

Please choose one of the following:

L – list all available events

IR – individual registration

GR – group registration

Q – quit

Enter your choice: X

Invalid input

 

Please choose one of the following:

L – list all available events

IR – individual registration

GR – group registration

Q – quit

 

 

Enter your choice: L

 

SJH23354 Success in Life Library Meeting Room 28 FULL

IVA56742 Seminar prep High Rise 151 49 seats

SPA49492 Career Fair. Theatre Unlimited

WJH99051 Working with others Fitch Hall 28 10 seats

 

Please choose one of the following:

L – list all available events

IR – individual registration

GR – group registration

Q – quit

Enter your choice: IR

For which event? XXX

Sorry, no matching order was found.

Enter your choice: IR

For which event? SJH23354

Sorry, we have reached the maximum number of seats for this event.

Please choose one of the following:

L – list all available events

IR – individual registration

GR – group registration

Q – quit

Enter your choice: IR

For which event? IVA56742

Registration successful.

 

Enter your choice: L

SJH23354 Success in Life Library Meeting Room 28 FULL

IVA56742 Seminar prep High Rise151 49 seats

SPA49492 CareerFair. Theatre Unlimited

WJH99051 Working with others Fitch Hall 28 10 seats

 

Please choose one of the following:

L – list all available events

IR – individual registration

GR – group registration

Q – quit

Enter your choice: GR

For which event? WJH99051

How many seats? 9

Registration successful

Enter your choice: L

SJH2335 Success in Life Library Meeting Rooml 28 FULL

IVA5674 Seminar Prep High Rise 151 49 seats

SPA4949 Career Fair. Theatre Unlimited

WJH9905 Working in Teams Fitch Hall 28 1 seat

Please choose one of the following:

L – list all available events

IR – individual registration

GR – group registration

Q – quit

Enter your choice: Q

Goodbye!

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education