Hoe do I fix the code: zyLabsUnitTest.java:20: error: no suitable constructor found for Movie(String,int,boolean,String[]) m = new Movie("Some Flick", 90, false, cast1); ^ constructor Movie.Movie() is not applicable (actual and formal argument lists differ in length) constructor Movie.Movie(String,int,boolean,int,String[]) is not applicable (actual and formal argument lists differ in length) zyLabsUnitTest.java:30: error: cannot find symbol answer = m.doArraysMatch(null, null); ^ symbol: method doArraysMatch(,) location: variable m of type Movie zyLabsUnitTest.java:36: error: cannot find symbol answer = m.doArraysMatch(cast1, null);
Hoe do I fix the code:
zyLabsUnitTest.java:20: error: no suitable constructor found for Movie(String,int,boolean,String[]) m = new Movie("Some Flick", 90, false, cast1); ^
constructor Movie.Movie() is not applicable (actual and formal argument lists differ in length) constructor Movie.Movie(String,int,boolean,int,String[]) is not applicable (actual and formal argument lists differ in length) zyLabsUnitTest.java:30: error: cannot find symbol answer = m.doArraysMatch(null, null);
^
symbol: method doArraysMatch(<null>,<null>) location: variable m of type Movie zyLabsUnitTest.java:36: error: cannot find symbol answer = m.doArraysMatch(cast1, null);
^
symbol: method doArraysMatch(String[],<null>) location: variable m of type Movie zyLabsUnitTest.java:42: error: cannot find symbol answer = m.doArraysMatch(cast1, cast2);
^
symbol: method doArraysMatch(String[],String[]) location: variable m of type Movie zyLabsUnitTest.java:48: error: cannot find symbol answer = m.doArraysMatch(cast1, cast3);
^
symbol: method doArraysMatch(String[],String[]) location: variable m of type Movie zyLabsUnitTest.java:54: error: cannot find symbol answer = m.doArraysMatch(cast3, cast4);
^
symbol: method doArraysMatch(String[],String[]) location: variable m of type Movie
Code:
import java.util.Arrays;
public class Movie {
String movieName;
int numMinutes;
boolean isKidFriendly;
int numCastMembers;
String castMembers[] = new String[10];
// Non-parameterized constructor
public Movie() {
this.movieName = "Flick";
this.numMinutes = 0;
this.isKidFriendly = false;
this.numCastMembers = 0;
}
// Parameterized constructor
public Movie(String movieName, int numMinutes, boolean isKidFriendly, int numCastMembers, String[] castMembers) {
this.movieName = movieName;
this.numMinutes = numMinutes;
this.isKidFriendly = isKidFriendly;
this.numCastMembers = numCastMembers;
this.castMembers = castMembers;
}
// getter and setters
public String getMovieName() {
return movieName;
}
public void setMovieName(String movieName) {
this.movieName = movieName;
}
public int getNumMinutes() {
return numMinutes;
}
public void setNumMinutes(int numMinutes) {
this.numMinutes = numMinutes;
}
public boolean isKidFriendly() {
return isKidFriendly;
}
public void setKidFriendly(boolean isKidFriendly) {
this.isKidFriendly = isKidFriendly;
}
public int getNumCastMembers() {
return numCastMembers;
}
public void setNumCastMembers(int numCastMembers) {
this.numCastMembers = numCastMembers;
}
public String[] getCastMembers() {
return castMembers;
}
public void setCastMembers(String[] castMembers) {
this.castMembers = castMembers;
}
public String toString() {
return "Movie name: "+movieName+"\n Num Minutes: "+numMinutes+"\nIs Kid Friendly: "+isKidFriendly+"\nNum cast memebers: "+numCastMembers+"\nCast Members: "+Arrays.toString(castMembers);
}
//Main funtion
public static void main(String args[]) {
//Printing default values
System.out.println("-----------------------Default values------------------------");
Movie m = new Movie();
System.out.println(m);
//printing setter new value
String castMembers[] = {"Ram", "Charan", "Swami","Ganesh","Namita","Babita","Anunay","Shikhar","Dravin","peter"};
Movie movie = new Movie("Avengers End game", 150, true, 25, castMembers);
System.out.println("------------------------New setter values------------------");
System.out.println(movie);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps