subject

Modify the program to have a command to delete a reservation.

Modify the program to define and use a method public void makeSeatReservations(Scanner scnr) so that the program's main() is cleaner. The makeSeatReservations() method should have a Scanner object passed to it to read the user's input.

import java. util. ArrayList;
import java. util. Scanner;

public class SeatReservation {

// Arraylist for seat reservations
private ArrayList allSeats;

public SeatReservation() {
allSeats = new ArrayList();
}

public void makeSeatsEmpty() {
int i;
for (i = 0; i < allSeats. size(); ++i) {
allSeats. get(i).makeEmpty();
}
}

public void printSeats() {
int i;
for (i = 0; i < allSeats. size(); ++i) {
System. out. print(i + ": ");
allSeats. get(i).print();
}
}

public void addSeats(int numSeats) {
int i;
for (i = 0; i < numSeats; ++i) {
allSeats. add(new Seat());
}
}

public Seat getSeat(int seatNum) {
return allSeats. get(seatNum);
}

public void setSeat(int seatNum, Seat newSeat) {
allSeats. set(seatNum, newSeat);
}

// Main method to use SeatReservation methods
public static void main (String [] args) {
Scanner scnr = new Scanner(System. in);
String usrInput = "";
String firstName, lastName;
int amountPaid;
int seatNum;
Seat newSeat;
SeatReservation ezReservations = new SeatReservation();

// Add 5 seat objects
ezReservations. addSeats(5);

// Make all seats empty
ezReservations. makeSeatsEmpty();

while (!usrInput. equals("q")) {
System. out. println();
System. out. print("Enter command (p/r/q): ");
usrInput = scnr. next();

// Print seats
if (usrInput. equals("p")) {
ezReservations. printSeats();
}

// Reserve a seat
else if (usrInput. equals("r")) {
System. out. print("Enter seat num: ");
seatNum = scnr. nextInt();

if ( !(ezReservations. getSeat(seatNum).isEmpty()) ) {
System. out. println("Seat not empty.");
}
else {
System. out. print("Enter first name: ");
firstName = scnr. next();
System. out. print("Enter last name: ");
lastName = scnr. next();
System. out. print("Enter amount paid: ");
amountPaid = scnr. nextInt();

// Create new Seat object and add to the reservations
newSeat = new Seat();
newSeat. reserve(firstName, lastName, amountPaid);
ezReservations. setSeat(seatNum, newSeat);

System. out. println("Completed.");
}
}
// FIXME: Add option to delete reservations
else if (usrInput. equals("q")) { // Quit
System. out. println("Quitting.");
}
else {
System. out. println("Invalid command.");
}
}
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:30
Assignment directions the owner of a popular local coffee shop has approached you to design a network for his business. he would like to offer his customers wifi access to the internet, but also thinks it might be handy to network the kitchen and store room together with the office computer he already uses for ordering, scheduling, and payroll. he thinks that might save him time doing inventory control and ordering. your assignment is to create a set of questions for him that will precisely define the purpose of the network and any constraints and restrictions on its implementation. assignment guidelines create a list of at least ten questions to ask your customer. of those ten questions, at least one question must come from each of the following subject areas: purpose of the network network access and security issue network availability and fault tolerance issues future expansion issues vendor issues briefly explain in two or three sentences why you would ask each question and what you expect to learn from your customer’s response. submission requirements your questions should meet the criteria of a good survey question by being specific, unambiguous, and closed-ended. all questions, as well as your explanations, should be written in proper english using correct grammar, spelling, and punctuation. use complete sentences, and do not use slang, texting abbreviations, or shortcuts.
Answers: 3
question
Computers and Technology, 22.06.2019 08:00
Aplan to budget time for studying and activities is referred to as a study routine. study habits. study skills. a study schedule.
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Whats are the different parts of no verbal comunication, especially body language?
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. peter has launched a website that features baby products. however, clients often find they are unable to access the website because the server is down. which feature of cybersecurity should peter focus on for his website? a. data authenticity b. data privacy c. data availability d. data integrity e. data encryption
Answers: 3
You know the right answer?
Modify the program to have a command to delete a reservation.

Modify the program to defi...
Questions
question
Mathematics, 23.03.2021 05:20
question
Mathematics, 23.03.2021 05:20
question
English, 23.03.2021 05:20
question
History, 23.03.2021 05:20
question
Mathematics, 23.03.2021 05:20