Question: I need help fixing MovieSeating.java. All other files were premade and are fine. Here are the codes: Assignment7.java import java.io.*; public class Assignment7 { public

I need help fixing MovieSeating.java. All other files were premade and are fine. Here are the codes: Assignment7.java
import java.io.*;
public class Assignment7 { public static void main(String[] args) throws IOException {
MovieSeating theatreSeating; Customer tempCustomer; int row, col, rowNum, columnNum; String line, fileName;
// create InputStreamReader and BufferedReader object // to read input from a KEYBOARD. InputStreamReader isr = new InputStreamReader(System.in); BufferedReader stdin = new BufferedReader(isr);
// Ask a user to enter a number of rows for a movie theatre seating from a KEYBOARD. System.out.println("Please enter a number of rows for a movie theatre seating."); rowNum = Integer.parseInt(stdin.readLine());
// Ask a user to enter a number of columns for a movie theatre seating from a KEYBOARD. System.out.println("Please enter a number of columns for a movie theatre seating."); columnNum = Integer.parseInt(stdin.readLine());
// instantiate a MovieSeating object theatreSeating = new MovieSeating(rowNum, columnNum);
// get a file name read from a KEYBOARD. System.out.println("Please enter a file name"); fileName = stdin.readLine();
// create FileReader and BufferedReader object to // read from a file. FileReader fr = new FileReader (fileName); BufferedReader inFile = new BufferedReader (fr);
/*** reading a customer's information from a FILE ***/ line = inFile.readLine();
/*** we will read line by line until we read the end of a given file ***/
}
} Customer.java
import java.util.StringTokenizer; import java.text.NumberFormat;
public class Customer { private String lastName; private String firstName; private int customerID; private int matineeTickets; private int normalTickets; private double totalCost;
// This constructor sets the first name and last name to "???", customer ID, // the number of matinee tickets, and the number of normal tickets to 0, // and the total cost to 0.0. public Customer() { lastName = "???"; firstName = "???"; customerID = 0; matineeTickets = 0; normalTickets = 0; totalCost = 0.0; } // This constructor constructs a Customer object given the last name, // first name, customer id, the number of matinee tickets, the number // of normal tickets. public Customer(String customerInfo) { String []tokenizer = customerInfo.split(" "); firstName = tokenizer[0].trim(); lastName =tokenizer[1].trim(); customerID = Integer.parseInt(tokenizer[2].trim()); matineeTickets = Integer.parseInt(tokenizer[3].trim()); normalTickets = Integer.parseInt(tokenizer[4].trim()); totalCost = 0.0; computeTotalCost(); }
// This constructor cConstructs a Customer object using the string containing customer's info. // It uses the StringTokenizer to extract first name, last name, id, the number of matinee tickets, // and the number of normal tickets. public Customer(String lName, String fName, int id, int matineeNum, int normalNum) { lastName = lName; firstName = fName; customerID = id; matineeTickets = matineeNum; normalTickets = normalNum; totalCost = 0.0; computeTotalCost(); }
// This method sets the last name. public void setLastName(String lName) { lastName = lName; } // This method sets the first name. public void setFirstName(String fName) { firstName = fName; } // This method sets the customer ID. public void setCustomerID(int id) { customerID = id; }
// This method set the value of number of matineeTickets to have its parameter value. // And it re-computes total cost. public void setMatineeTickets(int matinee) { matineeTickets = matinee; computeTotalCost(); }
// This method set the value of number of notmalTickets to have its parameter value. // And it re-computes total cost. public void setNormalTickets(int normal) { normalTickets = normal; computeTotalCost(); }
// This method returns the last name. public String getLastName() { return lastName; } // This method returns the first name. public String getFirstName() { return firstName; }
// This method returns the customer ID. public int getCustomerID() { return customerID; }
// This method returns the number of matinee tickets. public int getMatineeTickets() { return matineeTickets; }
// This method returns the number of normal tickets. public int getNormalTickets() { return normalTickets; }
// This method returns the total cost. public double getTotalCost() { return totalCost; }
// This method compute the total cost based on the number of matinee tickets and normal tickets. private void computeTotalCost() { totalCost = (5.00)*matineeTickets + (7.50)*normalTickets; }
// This method checks if a customer object passed as a parameter and itself (customer object) // are same using their last names, first names, and customerIDs. public boolean equals(Customer other) { if (lastName.equals(other.lastName) && firstName.equals(other.firstName) && (customerID == other.customerID) ) return true; else return false; } // This method compares a customer object passed as a parameter to itself (customer object) // are same using their total costs. public Customer hasMore(Customer other) { if (totalCost >= other.totalCost) return this; else return other; }
// This method returns a string containing a customer's initials // (first characters of firstName and lastName.) public String toString() { String result = firstName.charAt(0) + "." + lastName.charAt(0) + "."; return result; }
} // end of the class Customer
MovieSeating.java
public class MovieSeating {
private Customer[][] seating; public MovieSeating(int rowNum, int columnNum){ seating = new Customer[rowNum][columnNum]; for (int i = 0; i
private Customer getCustomerAt(int row, int col){ return seating[row][col];}
public boolean assignCustomerAt(int row, int col, Customer tempCustomer){ Customer cur = seating[row][col]; if (cur.getLastName().equals("???") && cur.getFirstName().equals("???")) { seating[row][col] = tempCustomer; return true;} else return false;} public boolean checkBoundaries(int row, int col){ if (row = seating.length || col >= seating[0].length){ return false;} else{ return true;}} // toString prints the seating array public String toString(){ String output = "The current seating " + "--------------------" + seating; for (int i = 0; i CustomerData.txt Bob Sponge 111111111 3 4 Pika Chu 222222222 6 5 Charlie Brown 333333333 4 3 Donald Trump 555666777 4 5 Thomas Jefferson 666888999 16 5 Snow White 777777777 43 23 George Washington 888888888 2 4
Write a program that reads customers' information from a file, and creates a movie theatre seating with a number of rows and columns specified by a user. Then it will attempt to assign each customer to a seat in a movie theatre. You will be creating a class called MovieSeating. This class should be defined in a file named NovieSeating.java. The class MovieSeating will contain a 2 dimensional array called seating of Cuatoner objects as its in- stall We will be usinx the followiut files. These files are complete. The last file is an input file (text file) that will be read from the Assignnent7 class. Save all of the files in the same The class MovieSeating st include the following constructor and methods. (If your class does not contain any of the following methods, points will be deducted.) public MovieSeat ing(int rowNun, int columnNun). It instantiates a two dinen sional array of the size rowum by columnNun specified by the parameters. Then it initializes each customer element of this array using the constructor of the class Custoner without any parameter. So each customer will have default values for its instance variables private Customer getCustonerAt (int rou, int col) It returns a customer at the indexes rou and col (specified by the parameters of this method) of the array seating. public boolean assignCustoserAt (int row, int col, Custoner tempCustoner) The method attempts to assign tempCustoner to the seat at ro and col (specified by the parameters of this method). If the seat has a default custollier. i.e., a customer with the last name .??7" and the first name ???" then we can assign the new customer tempCustoner to that seat and the method returns true. Otherwise, this seat is considered to be taken by someone else, the method does not assign the customer and returns false public boolean checkBoundaries(int rov, int col) The method checks if the parameters rou and col are valid. If at least one of the parameters rou or col is less than 0 or larger than the last index of the array (note that the size of rows and columns can be different), then it returns false. Otherwwise it returns true. .public String toString) - Returns a String containing information of the seating. It should show the list of customers assigned to the seating using the toString method of the class Custoser it shows initials of each customer) and the following format: The current seating B.C. H.C. 7.7 Please see the sample output listed below Helpful Hints Work on it in steps write one method, test it with a test driver and make sure it works before going on to the next met.hod . Always make sure your code compiles before you add another method. Your methods should be able to be called in any order Sample Output Make sure that your program works at least with this scenario (the inputs entered by a user are shown in bold). Please enter a number of rows for a movie theatre seating Please enter a number of columns for a movie theatre seating. Please enter a file name customerData.txt A customer information is read from a file Please enter a row number where the customer wants to sit Please enter a column number where the customer wants to sit. The seat at row 1 and coln 2 is assigned to the custoner G.B. The current seating A customer information is read from a file Please enter a row nunber where the custotner wants to sit Please enter a coumn umber where the customer wants to sit. The seat at row 2 and column 0 is assigned to the customer B.C The current seating A customer information is read from a file. Hilary Clinton/444444444/5/3 Please enter a row nunber where the customer wants to sit Please enter a column number where the customer wants to sit. The seat at row 2 and coln 1 is assigned to the customer IH.C. The current seating B.C. H.C. ?.? A customer information is read from a file. Please enter a row number where the custoner wants to sit Please enter a column umber where the eustomer wants to sit. The seat at row 0 and column 0 is assignmed to the customer C.B The current seating A customer information is read from a file David Beckham/555666777/4/5 Please enter a row nunber where the custoner wants to sit Please enter a column number where the customer wants to sit. Row or column number is not valid A customer David Beckham is not assigned a seat A customer information is read from a file David Johnson/666888999/16/5 Please enter a row nunber where the custoner wants to sit 2 Please enter a column number where the customer wants to sit, The seat is taken A custoner information is read from a file Please enter a row number where the customer wants to sit. Please enter a column mber where the customer wants to sit. Row or column number is not valid A customer Snow White is not assigned a seat. A custoner information is read from a file. Elvis Presley/888888888/2/4 Please enter a row number where the customer wants to sit. 0 Please enter a column number where the customer wants to sit. The seat at row 0 and column 2 is assigned to the customer E.P. The current seating C.B. ?.2. E.P
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
