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

Include UML. In Java, create a class for representing a movie theatre called Cin

ID: 3706683 • Letter: I

Question

Include UML. In Java, create a class for representing a movie theatre called Cinema with the following properties: -A private static int data value named cinemaCounter that starts at 1000 and increments for each new restaurant item that is created -A private array of string values called showings -A private int value called cinemaID -A boolean value called openClosed -A no-argument constructor that creates a new Cinema object and performs the following: -Sets cinemaID to cinemaCounter, then increments cinemaCounter -Sets openClosed to false (closed) -Sets showings to be size 3 with no values inside -A two-argument constructor that creates a new Cinema object, accepts an int value, accepts a boolean value, and performs the following: - Sets cinemaID to cinemaCounter, then increments cinemaCounter -Sets openClosed to the boolean value -Sets the length of showings to the int value - A void method called setShowings() that allows the user to input string values to populate the menu array -A void method called setShowingsEasy() that sets the first three indexes of the menu array to the following: "Oscar Bait”, “Superhero Movie”, “Romantic Comedy” -A void method called details() that prints out the following properties of a Cinema: cinemaID and whether or not the cinema is open. If the cinema is open, details() will print the list of showings. In the main method, perform the following: -Create 3 new Cinema objects -The first Cinema should have the default parameters -The second restaurant should be open and have a menu size of 2 -The third restaurant should be closed and have a menu size of 3 -Change the first Cinema’s openClosed value to true -Call setMenuEasy() for the 1st cinema -Call setMenu() for the 2nd cinema -Call details() for all three cinemas.

Include the UML diagram for the Cinema class.

*Program header and pseudocode
*Include a screenshot of the output of the details() calls

Explanation / Answer

CODING:

/**
* The java program Restaurant that set
* store id, a string of menu items, state of
* restaurant .
* */
//Restaurant.java
import java.util.Scanner;
public class Restaurant
{
   //static variable set to 1
   private static int storeCounter=1;
   //instance data members of the class
   private String Menu[];
   private int StoreID;
   private boolean OpenClosed;

   /*
   * Restaurant constructor that sets
   * the store counter to store id
   * and increment the storecounter,
   * state of the restaurant and
   * size of the menu as 3
   * */
   public Restaurant()
   {
       StoreID=storeCounter;
       storeCounter++;
       OpenClosed=true;
       Menu=new String[3];
   }
   /*
   * Parameter constructor that sets
   * storeID, increment store counter,
   * state of the restaurant
   * and size of the Menu of string type
   * */
   public Restaurant(int size,
           boolean OpenClosed)
   {
       StoreID=storeCounter;
       storeCounter++;
       this.OpenClosed=OpenClosed;
       Menu=new String[size];      
   }
   /*
   * Method setMenuEasy that set the
   * 3 menu items
   * */
   public void setMenuEasy()
   {
       Menu[0]="Hamburger";
       Menu[1]="Hot dog";
       Menu[2]="Pizza";
   }
   /*Method Details that displays store id , menu items
   * and state of the restaurant*/
   public void Details()
   {
       System.out.printf("StoreID: %-10d ",StoreID);
       System.out.printf("Menu Items ");
       for (int i = 0; i < Menu.length; i++) {
           System.out.printf("%s ",Menu[i]);  
       }          
       System.out.println("Is Open ?"+OpenClosed);
   }

   /*Method setMenu that prompts user to enter
   * menu items */
   public void setMenu()
   {
       Scanner scanner=new Scanner(System.in);      
       for (int i = 0; i < Menu.length; i++)
       {
           System.out.printf("Enter menu item [%d]",i+1);;
           String item=scanner.nextLine();
           Menu[i]=item;
       }
   }
   //main method that implemnets the class Restaurant
   public static void main(String[] args)
   {
       //create an instance of Restaurant
       Restaurant res1=new Restaurant();
       /*The 2nd restaurant with menu size of 2 and
          it is open state*/
       Restaurant res2=new Restaurant(2,true);
       /*The 3nd restaurant with menu size of 2 and
          it is open state*/
       Restaurant res3=new Restaurant(3,false);      
       //calling setMenuEasy
       res1.setMenuEasy();
       res3.setMenuEasy();      
       //calling setMenu
       res2.setMenu();      
       //calling Details method
       res1.Details();
       res2.Details();
       res3.Details();
   }
}

OUTPUT:

Enter menu item [1]Roti
Enter menu item [2]Chapati
StoreID: 1       
Menu Items
Hamburger
Hot dog
Pizza
Is Open ?true
StoreID: 2       
Menu Items
Roti
Chapati
Is Open ?true
StoreID: 3       
Menu Items
Hamburger
Hot dog
Pizza
Is Open ?false