Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

My code is this: public void set Date (int month, int day, int year) { this.mont

ID: 3616072 • Letter: M

Question

My code is this:
public void set Date (int month, int day, int year)
{
this.month=monthString(month);
this.day = day;
this.year=year;
this.writeOutput();
}
The method writeOutput in this uses the instance variables month,day, year, but gives no object name for these instance variables.Every instance variable must belong to some object. To what objector objects do these instance variables in the definition ofwriteOutput belong?Did I rewrite the above corde correctly using"this" parameter? If not, please let me know how! Thank you =)

Explanation / Answer

I assume you're using either c++ or Java... If not, tellme... regardless of whether you're using c++ or Java, make sure younever use a space in any type of identifier, be it a function or avariable. I only say this because there is a space betweenthe words "set" and "Date" in the code you provided.

The next change is only if you're coding in C++. If so,you need to use "public:" to demarcate a section of publiclyaccessible variables/functions. If you're using Java, just ignorethe rest of this.
public: void setDate(int month, int day, int year) { ...
public: void setDate(int month, int day, int year) { ...
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote