Lab 3: Classes and Objects and 2D Arrays (100 pts)

due Monday, May 4 at 11:59pm on Canvas


Pair Programming Required - Or You Will Receive a 0
  • Both partners fill in, sign, date, and submit the pair programming contract
  • Upload the document along with your Lab code to Canvas.
  • Only one partner submits the Lab code on Canvas.
  • Both partners submit the contract.
  • Please make sure both your names are on all the files.
  • If you need help finding a partner, please contact me as soon as possible.


Movie Theater Ticket App
  • Write a program that allows a user to purchase movie tickets for a showing of one of three movies.
  • Your program will work with two files - a Movie.java and Theater.java file - which will interact with each other.
  • You should begin by creating three Movie objects which will store information about three movies
    • Select 3 movies of your choice to represent in your program.
  • Once the information has been stored, the program should welcome the user and ask the user to type in the name of one of the three movies
  • Then, the program should allow the user to select seats based on a seating chart, stored as a 2D array.
  • The user should be allowed to purchase as many tickets as desired (until the theater is sold out!)
  • At the end of the program, display the total number of seats purchased by the user as well at the total cost.
  • Below is the required starter code for this program.
    • Please do not alter this starter code. You can add to it only.
Movie.java File:
  • The Movie.java file contains 6 variables, storing information about the name, price, total number of tickets sold, and showtime of the movie, as well as a 2D array storing the seating chart for the movie.
  • Note that all seats should be open at the start of the program (open seats represented as "X")
  • Additionally, this class has 3 methods as described below

/**
 * @author
 * @author
 * Lab 3, Movie.java
 */
public class Movie {
    public String name;
    public double price;
    public String showTime;
    public final int SIZE = 9;
    public int ticketsSold;
    public String[][] seats = new String[SIZE][SIZE];
   
    /**
     * Assigns the value of "X" to each
     * seat in the seats array
     */
    public void initializeSeats() {
       
    }
   
    /**
     * Prints out information about the movie
     * in the format
     * <name>
     * Ticket Price: $<ticketPrice>
     * Show time: <showTime>
     * Note that there are no <> around the output
     * The <> mean fill in here
     */
    public void printMovieStats() {
       
    }
   
    /**
     * Prints out the seats array to the console
     * with row and column numbers
     * and with the placement of the SCREEN in
     * row 10
     * Along with the message "Here are the
     * available seats for <movieName>:"
     * Note that there are no <> around the output
     */
    public void printSeatingChart() {
       
    }
}

  • Note: you are not allowed to implement any additional methods aside from those whose signatures are provided or to alter the method signatures in any way from what is provided, or you will not receive credit for this assignment.
Theater.java File:
  • The Theater.java file contains a main method, and code to interact with the user and the Movie class.
  • In main, you should create 3 Movie objects of your choice.
  • Theater.java has an optional method described below. Note that you are not required to implement this method in your program.
  • You may optionally add any additional methods to this class that you would find useful.
  • When the program starts, the user should be presented with the three movie choices.
    • The user should be allowed to type both capital and lower case letters for the movie name.
  • The user can select one of the movies and purchase as many tickets as desired for that movie (see example output below).
  • Initially, the theater should be empty (all seats marked with "X" to indicate they are open).
  • As the user purchases tickets, the open seats should be replaced with a "T" (for taken).
  • The program should do some error checking to prevent the user from purchasing a seat that is already taken (see example output below).
  • At the end of the program, print the total number of tickets purchased and the total price (see sample output).
/**
 * @author
 * @author
 * Lab 3, Theater.java
 */

import java.util.Scanner;

public class Theater {
    public static void main(String[] args) {
        int row, col;
        String choice;
        Scanner input = new Scanner(System.in);
        Movie starWars = new Movie();
        starWars.name = "Star Wars: The Rise of Skywalker";
        starWars.price = 10.50;
        starWars.ticketsSold = 0;
        starWars.showTime = "9:00pm";
       
        starWars.initializeSeats();
       
        //Add two more movie objects here - movies of your choice!
       
        System.out.println("Welcome to the CineBucks Movie Theater!");
        System.out.println("\nBelow are our current movies and showtimes:\n");
       
       
        input.close();
    }
   
    /**
     * This method is optional, but can be used
     * to avoid repetitive code for each movie
     * menu option
     * @param m the Movie object, for the movie
     * selected by the user
     * @param input the Scanner object
     */
    public static void menuItem(Movie m, Scanner input) {
       
    }
}


  • When your program is working *identically* to the sample output shown below (except the movie names may differ), including the demonstrated error checking, please submit both Movie.java and Theater.java to Canvas.

Sample Output:

Welcome to the CineBucks Movie Theater!

Below are our current movies and showtimes:

Star Wars: The Rise of Skywalker
Ticket price: $10.50
Show time: 9:00pm

Little Women
Ticket price: $11.00
Show time: 6:50pm

1917
Ticket price: $14.95
Show time: 8:15pm

Enter the name of the movie: little women


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X X X X X X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Enter the rowcol of the seat to purchase: 23
Your ticket is confirmed!


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X T X X X X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Another seat (y/n)?: y


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X T X X X X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Enter the rowcol of the seat to purchase: 23

Sorry! That seat is already taken!
Please try again.


Another seat (y/n)?: y


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X T X X X X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Enter the rowcol of the seat to purchase: 24
Your ticket is confirmed!


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X T T X X X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Another seat (y/n)?: y


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X T T X X X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Enter the rowcol of the seat to purchase: 24

Sorry! That seat is already taken!
Please try again.


Another seat (y/n)?: y


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X T T X X X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Enter the rowcol of the seat to purchase: 25
Your ticket is confirmed!


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X T T T X X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Another seat (y/n)?: y


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X T T T X X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Enter the rowcol of the seat to purchase: 26
Your ticket is confirmed!


Here are the available seats for Little Women:

  1 2 3 4 5 6 7 8 9
1 X X X X X X X X X
2 X X T T T T X X X
3 X X X X X X X X X
4 X X X X X X X X X
5 X X X X X X X X X
6 X X X X X X X X X
7 X X X X X X X X X
8 X X X X X X X X X
9 X X X X X X X X X
*******SCREEN******

Another seat (y/n)?: n

You ordered 4 tickets for Little Women at 6:50pm.
Your total today is: $44.00.


Thank you! Please come again.

What to Submit:

  • Submit your completed Movie.java and Theater.java files (make sure both your names are written in a Javadoc comment at the top of both files) to Canvas. Note: don't erase the @author tags. They are an important part of the comment.
/** <-note 2 stars here
* @author Fill_In_Here
* @author Fill_In_Here
* CIS 36B, File_Name_Here
*/
  • One partner submits Movie.java and Theater.java. Both partners submit the pair programming contract.
    • 5 point deduction for a missing or blank contract.
    • 2 point deduction if the top section of the contract is not filled out completely
  • Please use the default package or remove any package statements from the top of your files before submission (5 point deduction).
  • Please do not submit your work as a zip file (5 point deduction).
  • Please make sure your code is properly indented before submitting (5 point deduction)
    • Go to Source->Format before you submit to autoformat your code


How You Will Be Graded:

  • 100 points: The assignment works as shown in the sample output. All required features are implemented and implemented correctly.
  • 80-100 points: The assignment works mostly as shown in the sample output. Most required features are implemented and implemented correctly. Wording or spacing choices may differ from those shown
  • 40-80 points: Some of the assignment works as shown in the sample output. Some required features are implemented and implemented correctly.
  • 10-40 points: Serious problems in implementation and little correspondence between sample output and what is shown. Few of the features implemented or implemented correctly.
  • 0 points: Code does not compile or outputs an error at runtime.