Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer in Java. NO Spacing The Java class called Holiday is started below. An object of class holiday represents a 1. holiday during the

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Please answer in Java.

NO Spacing The Java class called Holiday is started below. An object of class holiday represents a 1. holiday during the year. This class has three instance variables: name, which is a String representing the name of the holiday day, which is an int representing the day of the month of the holiday month, which is a String representing the month the holiday is in public class Holiday { private String name; private int day; private String month; // your code goes here } a. Write a constructor for the class Holiday, which takes a String representing the name, an int representing the day, and a String representing the month as its arguments, and sets the class variables to these values. b. Write a method insame Month. This method takes an object of the class Holiday as its argument and returns Boolean type. The month value of this argument (Holiday object) will be compared with the month instance variable and returns true if they have the same value, and false if they do not. C. Write a method avgDate which takes an array of type Holiday as its argument and returns a double that is the average of the day variables in the Holiday instances. You may assume that the array is full (i.e. does not have any null entries). 2. The class Movie is started below. An instance of class Movie represents a film. This class has the following three class variables: title, which is a String representing the title of the movie . studio, which is a String representing the studio that made the movie . rating, which is a String representing the rating of the movie (i.e. PG13, R, etc) public class Movie private String title; private String studio; private String rating; // your code goes here } a. Write a constructor for the class Movie, which takes a String representing the title of the movie, a String representing the studio, and a String representing the rating as its arguments, and sets the respective class variables to these values. b. Write a second constructor for the class Movie, which takes a String representing the title of the movie and a String representing the studio as its arguments, and sets the respective class variables to these values, while the class variable rating is set to "PG". C. Write three methods with the following definition to get the title and movie studios: a. String gettitle({ Return this.title: } b. String getStudio({ Return this studie: } C. String getRating0{ Return this.rating; 3. Write your third class and call it Assignment 3. This class is the main class where Holiday and Movie classes will be tested. Therefore, this class should have a main () method. In this class, do the following: A. Holiday class: 1. Write a piece of code to create two Holiday instances with the names independence Day, and xmasDay, The instances should have the following definitions: a. Independence Dax = ("Independence Day", 4, "July"); b. xmasDay = ("Christmas Day", 25, "December"); II. Write a line of code to create an array object of holiday class. Use array initialization shortcut to initialize Independence Day and xmasDay as the values of the array object III. Print the Comparison of the month variables in the two Holiday instances you created in (1) above. This is done by calling in Same Month method on one of the objects and pass the second object as the parameter. For example, lodependence Day.insame Month/xmasDay); IV. Print the average of the day variables in the Holiday instances you created by calling avgDate() method in holiday class on the array object. The array object you created in step Il above. B. Movie class: I. Write a piece of code to create two Movie instances with the names movie1 and II. movie2. The instances should have the following definitions: a. movie1 = ("Casino Royale", "Eon Productions", "PG13"); b. movie2 = ("A star is Born", "Warner Bros", "PG15") Write a line of code to create an array object of Movie class. Use array initialization shortcut to initialize movie1 and movie2 as the values of the array object Use for loop to go over each element of the array object. for loop, do the following: Print the title of the movie instances using the getTitle method in Movie III. a class. b. Print the studio of the movie instances using the getStudio method in Movie class. c. Print the rating of the movie instances using the getRating method in Movie class. IV. Your result should look like the following table: Title Studio Rating ======== ====== Casino Royale Eon Productions PG13 A star is Born Warner Bros PG15

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions