How do I make the Java code output? //import java.util.Arrays; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; // default constructor public Movie() { this.movieName = "Flick"; this.numMinutes = 0; this.isKidFriendly = false; this.numCastMembers = 0; this.castMembers = new String[10];    } // overloaded parameterized constructor public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) { this.movieName = movieName; this.numMinutes = numMinutes; this.isKidFriendly = isKidFriendly; //numCastMember is set to array length this.numCastMembers = castMembers.length; this.castMembers = castMembers;    } public String getMovieName() { return this.movieName;    } public int getNumMinutes() { return this.numMinutes;    } public boolean getIsKidFriendly() { return this.isKidFriendly;    } public boolean isKidFriendly() { return this.isKidFriendly;    } public int getNumCastMembers() { return this.numCastMembers;    } public String[] getCastMembers() { return this.castMembers.clone();    } //Setter methods public void setMovieName(String movieName) { this.movieName = movieName;    } public void setNumMinutes(int numMinutes) { this.numMinutes = numMinutes;    } public void setIsKidFriendly(boolean isKidFriendly) { this.isKidFriendly = isKidFriendly; } // set the number of minutes //replace cast memeber at index with new cast memeber //return false if index in invalid //else return true; //replace cast memeber at index with new cast memeber //return false if index in invalid //else return true; public boolean replaceCastMember(int index, String castMemberName) { if (index < 0 || index >= numCastMembers) return false; castMembers[index] = castMemberName; return true;    } /*alterante method if index is starting from 1    public boolean replaceCastMember(int index, String castMemberName) { if (index < 1 || index > numCastMembers) return false; castMembers[index-1] = castMemberName; return true;    } */ //compare two arrays //return true if thery are same else return false public boolean doArraysMatch(String[] arr1, String[] arr2) { if (arr1 == null && arr2 == null) return true; else if(arr1==null || arr2==null) return false; if (arr1.length == arr2.length) { for (int i = 0; i < arr1.length; i++) { //to ignore case compare lowercase version of both stirng if (arr1[i].toLowerCase().equals(arr2[i].toLowerCase()) == false) return false;    } return true;    } return false;    } //return comma separated name of castmembers public String getCastMemberNamesAsString() { if (numCastMembers == 0)    return "none"; String names = castMembers[0]; for (int i = 1; i < numCastMembers; i++) { names += ", " + castMembers[i];    } return names;    }    public String toString() { String friendly; if(isKidFriendly()) friendly= "is kid friendly"; else friendly="not kid freindly"; String minute=String.format("%03d",getNumMinutes()); return "Movie:"+ " [ Minutes "+minute+" "+ "| Movie Name: "+getMovieName()+" "+ "| "+friendly+" "+ "| Number of Cast Members: "+getNumCastMembers()+" "+ "| "        + "Cast Members: "+getCastMemberNamesAsString()+" "+ "]"; //return "Movie["+ "movieName ="+movieName + ",numMinutes ="+numMinutes + ",isKidfreindly ="+isKidFriendly + "numCastMembers ="+getCastMemberNamesAsString() + //",castMembers ="+castMembers+ "]";    } //"Movie: [ Minutes 142 | Movie Name: The Shawshank Redemption | not kid friendly | Number of Cast Members: 3 | Cast Members: Tim Robbins, Morgan Freeman, Bob Gunton ] }       //compare two movie object //return true if every member variable matches else return false public boolean equals(Object o){ // Movie m=(Movie)o; //return movieName.equals(m.getMovieName()) // && numMinutes==m.getNumMinutes() // && doArraysMatch(castMembers, m.getCastMembers()); if(o instanceof Movie){ Movie other = (Movie) o; if(movieName.equals(other.movieName)){ if(numMinutes == other.numMinutes){ if(isKidFriendly == other.isKidFriendly){ if(doArraysMatch(castMembers,other.castMembers)){ return true;    }    }    }    } } return false;    }    //main function to test the code //uncomment to use it. public static void main(String[] args){ Movie m1=new Movie(); System.out.println(m1); String[] cast=new String[]{"Tim Robbins","Morgan Freeman", "Bob Gunton"}; Movie m2=new Movie("The Shawshank Redemption",142,false,cast); System.out.println(m2); System.out.println("m1==m2 =: "+m2.equals(m1));    }    }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How do I make the Java code output?

//import java.util.Arrays;
public class Movie {
private String movieName;
private int numMinutes;
private boolean isKidFriendly;
private int numCastMembers;
private String[] castMembers;
// default constructor
public Movie() {
this.movieName = "Flick";
this.numMinutes = 0;
this.isKidFriendly = false;
this.numCastMembers = 0;
this.castMembers = new String[10];
  
}
// overloaded parameterized constructor
public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) {
this.movieName = movieName;
this.numMinutes = numMinutes;
this.isKidFriendly = isKidFriendly;
//numCastMember is set to array length
this.numCastMembers = castMembers.length;
this.castMembers = castMembers;
  
}
public String getMovieName() {
return this.movieName;
  
}
public int getNumMinutes() {
return this.numMinutes;
  
}
public boolean getIsKidFriendly() {
return this.isKidFriendly;
  
}
public boolean isKidFriendly() {
return this.isKidFriendly;
  
}
public int getNumCastMembers() {
return this.numCastMembers;
  
}
public String[] getCastMembers() {
return this.castMembers.clone();
  
}
//Setter methods
public void setMovieName(String movieName) {
this.movieName = movieName;
  
}
public void setNumMinutes(int numMinutes) {
this.numMinutes = numMinutes;
  
}
public void setIsKidFriendly(boolean isKidFriendly) {
this.isKidFriendly = isKidFriendly;
}
// set the number of minutes
//replace cast memeber at index with new cast memeber
//return false if index in invalid
//else return true;
//replace cast memeber at index with new cast memeber
//return false if index in invalid
//else return true;
public boolean replaceCastMember(int index, String castMemberName) {
if (index < 0 || index >= numCastMembers)
return false;
castMembers[index] = castMemberName;
return true;
  
} /*alterante method if index is starting from 1
  
public boolean replaceCastMember(int index, String castMemberName) {
if (index < 1 || index > numCastMembers)
return false;
castMembers[index-1] = castMemberName;
return true;
  
} */
//compare two arrays
//return true if thery are same else return false
public boolean doArraysMatch(String[] arr1, String[] arr2) {
if (arr1 == null && arr2 == null)
return true;
else if(arr1==null || arr2==null)
return false;
if (arr1.length == arr2.length) {
for (int i = 0; i < arr1.length; i++) {
//to ignore case compare lowercase version of both stirng
if (arr1[i].toLowerCase().equals(arr2[i].toLowerCase()) == false)
return false;
  
}
return true;
  
}
return false;
  
}
//return comma separated name of castmembers
public String getCastMemberNamesAsString() {
if (numCastMembers == 0)
   return "none";
String names = castMembers[0];
for (int i = 1; i < numCastMembers; i++) {
names += ", " + castMembers[i];
  
}
return names;
  
}
  
public String toString() {
String friendly;
if(isKidFriendly())
friendly= "is kid friendly";
else
friendly="not kid freindly";
String minute=String.format("%03d",getNumMinutes());
return "Movie:"+ " [ Minutes "+minute+" "+ "| Movie Name: "+getMovieName()+" "+ "| "+friendly+" "+ "| Number of Cast Members: "+getNumCastMembers()+" "+ "| "
       + "Cast Members: "+getCastMemberNamesAsString()+" "+ "]";
//return "Movie["+ "movieName ="+movieName + ",numMinutes ="+numMinutes + ",isKidfreindly ="+isKidFriendly + "numCastMembers ="+getCastMemberNamesAsString() +
//",castMembers ="+castMembers+ "]";
  
}
//"Movie: [ Minutes 142 | Movie Name: The Shawshank Redemption | not kid friendly | Number of Cast Members: 3 | Cast Members: Tim Robbins, Morgan Freeman, Bob Gunton ] }
  
  
//compare two movie object
//return true if every member variable matches else return false
public boolean equals(Object o){
// Movie m=(Movie)o;
//return movieName.equals(m.getMovieName())
// && numMinutes==m.getNumMinutes()
// && doArraysMatch(castMembers, m.getCastMembers());
if(o instanceof Movie){
Movie other = (Movie) o;
if(movieName.equals(other.movieName)){
if(numMinutes == other.numMinutes){
if(isKidFriendly == other.isKidFriendly){
if(doArraysMatch(castMembers,other.castMembers)){
return true;
  
}
  
}
  
}
  
}
}
return false;
  
}
  
//main function to test the code
//uncomment to use it.
public static void main(String[] args){
Movie m1=new Movie();
System.out.println(m1);
String[] cast=new String[]{"Tim Robbins","Morgan Freeman", "Bob Gunton"};
Movie m2=new Movie("The Shawshank Redemption",142,false,cast);
System.out.println(m2);
System.out.println("m1==m2 =: "+m2.equals(m1));
  
}
  
}

Attribute
movieName numMinutes isKidFriendly
numCastMembers
castMembers
Default Value
"Flick"
false
length of 10
Transcribed Image Text:Attribute movieName numMinutes isKidFriendly numCastMembers castMembers Default Value "Flick" false length of 10
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education