Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

do New Project § In BlueJ, create “New Project” named LASTNAME-theater-corp Use

ID: 3580675 • Letter: D

Question

do

New Project

§ In BlueJ, create “New Project” named LASTNAME-theater-corp

Use good programming style and Javadoc documentation standards

LASTNAME-theater-corp

CODE

Rating

Create “New Class…” for enumerated type named Rating

Declare the 3 possible values (as stated in requirements above on pg. 1)

Movie

Create “New Class…” named Movie to store the details of a movie

Declare the 2 fields for the movie details (as stated in requirements above)

Code Movie(String title, Rating rating) with initialization of the 2 fields

Code accessor method getTitle to return the title field

Code accessor method getRatingString to return a String representation of the rating field (MUST use toString method where necessary)

Theater

Create “New Class…” named Theater to store the details of a theater

Declare the 2 fields for the theater information (as stated in requirements)

Code a constructor with 1 parameter for initialization of the 2 fields

location field name MUST be SAME as parameter name and use this

MUST instantiate screens field appropriately

Code the appropriate accessor methods getLocation and getScreens

Code mutator method with the following header to add a movie to a screen:

public void addScreen(Integer screen, Movie movie)

TheaterCorp

Create “New Class…” named TheaterCorp

Declare the 3 fields for the theater corporation (as stated in requirements)

Code a constructor with 1 parameter for initialization of the 3 fields

corpName field name MUST be SAME as parameter name and use this

MUST instantiate both theaters and movies fields appropriately

Code accessor methods getCorpName, getTheaters and getMovies

Code the following mutator method to add a theater to the corporation:

public void addTheater(Theater theater)

Code the following overloaded methods to add a Movie to the movies collection for the theater corporation:

public void addMovie(Movie movie)

public void addMovie(String title, Rating rating)

Code a mutator method to return a boolean value after trying to sell (by removing) ALL theaters matching a certain location:

public boolean sellTheater(String location)

MUST first check if there are any theaters at all and (if not) just prints “NO THEATERS TO SELL”

MUST only use an Iterator with a for loop for iteration

MUST ensure that the searching for location matches even if the upper/lower-cases do not, but no need to worry about trimming or spaces (HINT: find a String method that eliminates case-sensitivity)

MUST print resulting message ONLY ONCE, if any Theater was:

sold (i.e. searched/found/removed), then prints (only one time) “SELLING THEATER - <location>”

otherwise, prints “NO THEATER LOCATION - <location>”

MUST return true if any Theater was sold … otherwise return false

CODE

TheaterCorp

(cont.)

In TheaterCorp, code a print method to output ALL the corporation’s movies:

public void listAllMovies( )

MUST first check if there are any movies at all and (if not) just prints “NO MOVIES EXIST”

MUST print heading “LIST OF MOVIES” (ONLY if >= 1 movie exists)

MUST use a for-each loop and print each Movie listing formatted as     “       <title> (<rating>)”      (e.g. “      Bambi (G)”)  

NOTE: the leading spaces in the formatting

Code method to print ALL movies now playing at ALL theaters:

public void listAllTheaterMovies( )

MUST first check if any theaters, or prints “NO THEATERS EXIST”

MUST print heading “NOW PLAYING!!” (ONLY if >= 1 theater exists)

MUST use a for-each loop to iterate through all existing theaters and:

MUST print formatted heading for each and every location listing as “LOCATION - <location>”       (e.g. “LOCATION   - Pitman”)

MUST then check the screens at that location and:

if none exists, prints “NO SCREENS EXIST”

MUST otherwise, use a for-each loop with keySet to print each Movie listing on each of the screens with the output formatted as “      SCREEN <key> - <title> (<rating>)”      (e.g. “      SCREEN 1 - Bambi (G)”)       NOTE: leading spaces

*****You don't have to do the last driver class part******

do

New Project

§ In BlueJ, create “New Project” named LASTNAME-theater-corp

Use good programming style and Javadoc documentation standards

LASTNAME-theater-corp

CODE

Rating

Create “New Class…” for enumerated type named Rating

Declare the 3 possible values (as stated in requirements above on pg. 1)

Movie

Create “New Class…” named Movie to store the details of a movie

Declare the 2 fields for the movie details (as stated in requirements above)

Code Movie(String title, Rating rating) with initialization of the 2 fields

Code accessor method getTitle to return the title field

Code accessor method getRatingString to return a String representation of the rating field (MUST use toString method where necessary)

Theater

Create “New Class…” named Theater to store the details of a theater

Declare the 2 fields for the theater information (as stated in requirements)

Code a constructor with 1 parameter for initialization of the 2 fields

location field name MUST be SAME as parameter name and use this

MUST instantiate screens field appropriately

Code the appropriate accessor methods getLocation and getScreens

Code mutator method with the following header to add a movie to a screen:

public void addScreen(Integer screen, Movie movie)

TheaterCorp

Create “New Class…” named TheaterCorp

Declare the 3 fields for the theater corporation (as stated in requirements)

Code a constructor with 1 parameter for initialization of the 3 fields

corpName field name MUST be SAME as parameter name and use this

MUST instantiate both theaters and movies fields appropriately

Code accessor methods getCorpName, getTheaters and getMovies

Code the following mutator method to add a theater to the corporation:

public void addTheater(Theater theater)

Code the following overloaded methods to add a Movie to the movies collection for the theater corporation:

public void addMovie(Movie movie)

public void addMovie(String title, Rating rating)

Code a mutator method to return a boolean value after trying to sell (by removing) ALL theaters matching a certain location:

public boolean sellTheater(String location)

MUST first check if there are any theaters at all and (if not) just prints “NO THEATERS TO SELL”

MUST only use an Iterator with a for loop for iteration

MUST ensure that the searching for location matches even if the upper/lower-cases do not, but no need to worry about trimming or spaces (HINT: find a String method that eliminates case-sensitivity)

MUST print resulting message ONLY ONCE, if any Theater was:

sold (i.e. searched/found/removed), then prints (only one time) “SELLING THEATER - <location>”

otherwise, prints “NO THEATER LOCATION - <location>”

MUST return true if any Theater was sold … otherwise return false

Explanation / Answer

import java.util.*;

import java.io.*;

public class Show

{

    

    String showName;

    String showDate;

    double collection;

    int numBookings;

    char[] seatStatus=new char[50];

    int numofseatsRemaining[]=new int[50];

    int[] freeSeats=new int[50];

    Booking[] booking=new Booking[50];

    

public Show( String showNameX, String showDateX)

{

    showDate=showDateX;

    showName=showNameX;

    

    for (int i = 0; i <= 49; i++)

    {

        seatStatus[i]='f';

    }

}

public String getShowName()

{

    return showName;

}

public String getShowDate()

{

    return showDate;

}

public char[] getAllSeatsStatus()

{

    return seatStatus;

}

public Booking[] getAllBookings()

{

    for(int i=0; i<booking.length; i++)

    {

        booking[i].getPersonID();

        booking[i].getDate();

        booking[i].getAmount();

    }

    return booking;

}

public int getNumSeatsRemaining()

{

    int numofseatsRemaining=0;

    for(int j=1; j<=50; j++)

    {

        if(getAllSeatsStatus()[j]=='f')

            numofseatsRemaining++;

    }

    return numofseatsRemaining;

}

public int getNumBookings()

{

    for(int i=0; booking[i]!=null; i++)

    {

        numBookings++;

    }

    return numBookings;

}

public int[]getFreeSeats()

{

    return numofseatsRemaining;

}

public double getCollection()

{

    return collection;

}

public void bookSeats(int seats[])

{

    

}

public boolean addBooking(Booking B)/>

{

    return true;

}

public void addToCollection(double amount)

{

    collection+=amount;

}

    

}