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 that lists the 4 events with format of: generated bar code, followed by event name, event location, and number of seats that are remaining for the event? 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:     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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 14RQ
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 that lists the 4 events with format of: generated bar code, followed by event name, event location, and number of seats that are remaining for the event?

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:

 

 

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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT