ALSO CREATE A UML DIAGRAM USING JAVA Create a class for representing a movie the
ID: 3709071 • Letter: A
Question
ALSO CREATE A UML DIAGRAM USING 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 cinemalD -A boolean value called openClosed -A no-argument constructor that creates a new Cinema object and performs the following: Sets cinemalD to cinemaCounter, then increments sinemaCounter 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 cinemalD to inemaCounter then increments cinemaCounter Sets openClosed to the boolean value -Sets the length of showings to the int value - A void method called setShowingsl) that allows the user to input string values to populate the menu array A void method called setShowingsEasv() 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: cinemalD 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 Cinema should be open and have a menu size of 2 The third Cinema should be closed and have a menu size of 3 -Change the first Cinema's gpenClosed value to true -Call setshowingsEasyl) for the 1t cinema Call setshowings() for the 2nd cinema Call details!) for all three cinemasExplanation / Answer
import java.util.Scanner;
public class Cinema {
private String[] showings;
private int cinemaId;
private boolean openClosed;
private int cinemaCounter = 1000;
public Cinema() {
cinemaCounter = cinemaCounter + 1;
this.cinemaId = cinemaCounter;
this.openClosed = false;
showings=new String[3];
}
public Cinema(int value, boolean flag)
{
this.cinemaId = cinemaCounter;
cinemaCounter++;
this.openClosed = false;
showings=new String[value];
}
public void setShowings()
{
Scanner scanner=new Scanner(System.in);
int length=showings.length;
for(int i=0;i<length;i++)
{
System.out.println("type movie name " );
String name=scanner.next();
showings[i]=name;
}
}
public void setShowingsEasy()
{
for(int i=0;i<showings.length;i++)
{
if(i==0)
{
showings[i]="oscarBait";
}
if(i==1)
{
showings[i]="superhero movie";
}
if(i==2)
{
showings[i]="Romantic comedy";
}
}
}
public void details()
{
System.out.println("the cinemaid "+cinemaId);
System.out.println("is cinema opened ?"+openClosed);
System.out.println("the list of showings");
for(int i=0;i<showings.length;i++)
{
System.out.println(showings[i]);
}
}
public static void main(String[] args) {
Cinema cinema1=new Cinema();
boolean open=true;
Cinema cinema2=new Cinema(2,open);
boolean open1=false;
Cinema cinema3=new Cinema(3,open1);
//change cinemaopenclosed
cinema1.openClosed=true;
cinema1.setShowingsEasy();
cinema2.setShowings();
cinema1.details();
cinema2.details();
}
}
output
type movie name
animation
type movie name
super hero
the cinemaid 1001
is cinema opened ?true
the list of showings
oscarBait
superhero movie
Romantic comedy
the cinemaid 1000
is cinema opened ?false
the list of showings
animation
super
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.