I need to override the toString() method with my own, however I am not sure how to reference back to the parameters for the constructor of the class. I've included my code below. I even tried giving the class instance variables of the same name, however the error said the code was "unreachable." What am I doing wrong? /** * Superclass for the different types of appointments. * TODO: Appointments have a description & date MM/DD/YYYY * TODO: method: occursOn(int year, int month, int day); * 4 method constructor: year, month, day, description */ public class Appointment { /** * the constructor method for an Appointment. * * @param year - the year of the appointment. * @param month - the month of the appointment. * @param date - the day of the appointment. * @param description - a short description of the appointment. */ publicAppointment(intyear, intmonth, intdate, Stringdescription){ } /** * Method to return a string representation of the appointment. * Will be inherited by the subclasses. * @return - a string representation of the appointment object. */ publicStringtoString(){   returnthis.description +" on "+this.month +"/"+this.day +"/"+this.year +". "; } }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question
100%

I need to override the toString() method with my own, however I am not sure how to reference back to the parameters for the constructor of the class. I've included my code below. I even tried giving the class instance variables of the same name, however the error said the code was "unreachable." What am I doing wrong?


/**
* Superclass for the different types of appointments.
* TODO: Appointments have a description & date MM/DD/YYYY
* TODO: method: occursOn(int year, int month, int day);
* 4 method constructor: year, month, day, description
*/
public class Appointment {



/**
* the constructor method for an Appointment.
*
* @param year - the year of the appointment.
* @param month - the month of the appointment.
* @param date - the day of the appointment.
* @param description - a short description of the appointment.
*/
publicAppointment(intyear, intmonth, intdate, Stringdescription){


}

/**
* Method to return a string representation of the appointment.
* Will be inherited by the subclasses.
* @return - a string representation of the appointment object.
*/
publicStringtoString(){
 
returnthis.description +" on "+this.month +"/"+this.day +"/"+this.year +". ";
}

}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning