Write a class called Movie that contains the following infor
Solution
Please find my code.
Please let me know in case of any issue.
######## Movie.java ###############
public class Movie {
// instance variables
private String title;
private String director;
private float duration;
// three argument constructor
public Movie(String title, String director, float duration){
// validating parameters
if(title==null || director==null || duration < 0.0){
throw new IllegalArgumentException(\"Please pass valid parameters.\");
}
this.title = title;
this.director = director;
this.duration = duration;
}
// getters and setters
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public float getDuration() {
return duration;
}
public void setDuration(float duration) {
this.duration = duration;
}
}
############ MovieTest.java ##############
public class MovieTest {
public static void main(String[] args) {
// creating Movie Object
Movie movie = new Movie(\"The Landon\", \"Teem Cook\", 3.2f);
System.out.println(\"Titls: \"+movie.getTitle());
System.out.println(\"Director: \"+movie.getDirector());
System.out.println(\"Duration: \"+movie.getDuration()+\" hours\");
}
}
/*
Sample Output:
Titls: The Landon
Director: Teem Cook
Duration: 3.2 hours
*/


