How do I fix the Java code errors?
Code:
//import java.util.Arrays;
//Movie.java
package movie;
public class Movie {
private String movieName;
private int numMinutes;
private boolean isKidFriendly;
private int numCastMembers;
private String[] castMembers;
public Movie() {
movieName = "Flick";
numMinutes = 0;
isKidFriendly = false;
numCastMembers = 0;
castMembers = new String[10];
}
public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) {
this.movieName = movieName;
this.numMinutes = numMinutes;
this.isKidFriendly = isKidFriendly;
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();
}
public void setMovieName(String movieName) {
this.movieName = movieName;
}
public void setNumMinutes(int numMinutes) {
this.numMinutes = numMinutes;
}
public void setIsKidFriendly(boolean isKidFriendly) {
this.isKidFriendly = isKidFriendly;
}
public boolean replaceCastMember(int index, String castMemberName) {
if (index < 0 || index > numCastMembers) {
return false;
}
castMembers[index] = castMemberName;
return true;
}
public boolean doArraysMatch(String[] arr1, String[] arr2) {
if (arr1 == null && arr2 == null) {
return true;
}
if (arr1.length == arr2.length) {
for (int i = 0; i < arr1.length; i++) {
if (arr1[i] != null && arr2[i] != null) {
if (! arr1[i].toLowerCase().equals(arr2[i].toLowerCase())) {
return false;
}
}
}
return true;
}
return false;
}
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 = "kid friendly";
} else {
friendly = "not kid freindly";
}
return "Movie:" + " [ Minutes " + getNumMinutes() + " " + "| Movie Name: " + getMovieName() + " " + "| "
+ friendly + " " + "| Number of Cast Members: " + getNumCastMembers() + " " + "| Cast Members: "
+ getCastMemberNamesAsString() + " " + "]";
}
public boolean equals(Object o) {
Movie m = (Movie) o;
return movieName.equals(m.getMovieName()) && numMinutes == m.getNumMinutes()
&& doArraysMatch(castMembers, m.getCastMembers());
}
public static void main(String[] args) {
Movie movie = new Movie("The Shawshank Redemption", 142, false,
new String[] { "Tim Robbins", "Morgan Freeman", "Bob Gunton" });
Movie movie1 = new Movie(" Aladin", 90, true,
new String[] { "Scott Weigner", "Robin Williams", "Linda Larkin", "Jonathan Freeman" });
String[] castMembers = new String[] { "Tim Robbins", "Morgan Freeman", "Bob Gunton" };
System.out.println(movie.toString());
System.out.println(movie1.toString());
System.out.println("\ncast members are same : "+movie.doArraysMatch(movie.castMembers, castMembers));
System.out.println("\nCast Members of movie 1 "+movie1.getCastMemberNamesAsString());
}
}
Errors:
-java:17: error: cannot access Movie Movie m = null;
-java:15: error: cannot access Movie Movie m = null;
-java:29: error: cannot access Movie Movie m1 = null;
-java:26: error: cannot access Movie Movie m1 = null;
-java:16: error: cannot access Movie field = Movie.class.getDeclaredField(str);
- java:13: error: cannot access Movie constructor = Movie.class.getConstructor();
-java:13: error: cannot access Movie constructor = Movie.class.getConstructor(String.class, int.class, boolean.class,
String[].class);
- java:12: error: cannot access Movie Method methodGetNumMinutes = Movie.class.getMethod("getNumMinutes");
-java:12: error: cannot access Movie Method methodSetNumMinutes = Movie.class.getMethod("setNumMinutes", int.class);
- java:12: error: cannot access Movie Method replaceCastMember = Movie.class.getMethod("replaceCastMember", int.class, String.class);
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 9 images
- True or False A Java method can be defined to accept a varying number of parameters.arrow_forwardLab 9 C balance the same, y, n, why? class CheckingAct { . . . . private int balance; public void processCheck( int amount ) { int charge; if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // change the local copy of the value in "amount" amount = 0 ; } } public class CheckingTester { public static void main ( String[] args ) { CheckingAct act; int check = 5000; act = new CheckingAct( "123-345-99", "Your Name", 100000 ); System.out.println( "check:" + check ); // prints "5000" // call processCheck with a copy of the value 5000 act.processCheck( check ); System.out.println( "check:" + check ); // prints "5000" --- "check" was not changed } }arrow_forward1 a. is the amount the same, yes or no, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { balance = balance + amount ; } // modified toString() method public String toString() { return "Account: " + actNum + "\tName: " + nameOnAct + "\tBalance: " + amount ; } } b. public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { // scope of amount starts here balance = balance + amount ; // scope of amount ends here } public void processCheck( int amount ) { // scope of amount starts here int charge; incrementUse(); if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // scope of amount ends here } } c. is the…arrow_forward
- Statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is: There are 15 people.arrow_forwardJavaarrow_forwardQ1. amount the same, y, n, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { balance = balance + amount ; } // modified toString() method public String toString() { return "Account: " + actNum + "\tName: " + nameOnAct + "\tBalance: " + amount ; } } Q2. amount the same, y, n, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { // scope of amount starts here balance = balance + amount ; // scope of amount ends here } public void processCheck( int amount ) { // scope of amount starts here int charge; incrementUse(); if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // scope of amount ends here }…arrow_forward
- public class KnowledgeCheckTrek { public static final String TNG = "The Next Generation"; public static final String DS9 = "Deep Space Nine"; public static final String VOYAGER = "Voyager"; public static String trek(String character) { if (character != null && (character.equalsIgnoreCase("Picard") || character.equalsIgnoreCase("Data"))) { // IF ONE return TNG; } else if (character != null && character.contains("7")) { // IF TWO return VOYAGER; } else if ((character.contains("Quark") || character.contains("Odo"))) { // IF THREE return DS9; } return null; } public static void main(String[] args) { System.out.println(trek("Captain Picard")); System.out.println(trek("7 of Nine")); System.out.println(trek("Odo")); System.out.println(trek("Quark")); System.out.println(trek("Data").equalsIgnoreCase(TNG));…arrow_forwardT/F 1. Java methods can only return primitive typesarrow_forwardusing System; class Program { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { Console.WriteLine(number); number = number + 2; } int[] randNo = newint[88]; Random r = new Random(); int i=0; while (number <= 88) { randNo[i] = number; number+=1; i+=1; } for (i = 0; i < 3; i++) { Console.WriteLine("Random Numbers between 1 and 88 are " + randNo[r.Next(1, 88)]); } } } this code counts from 1-88 in odds and then selects three different random numbers. it keeps choosing 0 as a random number everytime. how can that be fixed?arrow_forward
- using System; class main { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { int i; Random r = new Random(); int[] randNo=newint[3]; for(i=0;i<3;i++) { randNo[i]= r.Next(1,88); Console.WriteLine("Random Number between 1 and 88 is "+randNo[i]); } } } } This code is supposed to count from 1-88 and then select three random numbers from the list but instead it generates an infinite loop of random numers between 1-88. how can it be fixed?arrow_forwardImage attachedarrow_forwardFix all the errors and send the code please // Application looks up home price // for different floor plans // allows upper or lowercase data entry import java.util.*; public class DebugEight3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String entry; char[] floorPlans = {'A','B','C','a','b','c'} int[] pricesInThousands = {145, 190, 235}; char plan; int x, fp = 99; String prompt = "Please select a floor plan\n" + "Our floorPlanss are:\n" + "A - Augusta, a ranch\n" + "B - Brittany, a split level\n" + "C - Colonial, a two-story\n" + "Enter floorPlans letter"; System.out.println(prompt); entry = input.next(); plan = entry.charAt(1); for(x = 0; x < floorPlans.length; ++x) if(plan == floorPlans[x]) x = fp; if(fp = 99) System.out.println("Invalid floor plan code entered")); else { if(fp…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education