Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. Create a class called Holiday to represent a holiday. An object of class Holiday represents a holiday during the year. This class has three
3. Create a class called Holiday to represent a holiday. An object of class Holiday represents a 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. 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. Provide a mutator method (set) and accessor method (get) for each instance variable. c. Write a method in SameMonth, which compares two instances of the class Holiday, and returns the Boolean value true if they have the same month, and false if they do not. d. Write a method toString that prints the message: The holiday is "name" and it is on month, day. Where name, month and day are the name, month and day of the holiday. e. Write a piece of code that creates a Holiday instance with the name "National Day", with the day "16", and with the month "December", then call the method toString() to print the holiday information
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started