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

I have a properly functioning Day class, as well as TimeOfDay class. I am now tr

ID: 3621264 • Letter: I

Question

I have a properly functioning Day class, as well as TimeOfDay class. I am now trying to create an Appointment class that has 2 TimeOfDay objects (start & end), one Day object, and a String description of what that appointment pertains to. Here is what I have so far in the appointment class.

public class Appointment
{
private TimeOfDay start;
private TimeOfDay end;
private String description = " ";
private Day aDay;

public Appointment(Day aDay,TimeOfDay start, TimeOfDay end, String description)
{
start = new TimeOfDay start;
end = new TimeOfDay end;
day = aDay;
description = String description;


}

This is not right and I have tried several options with zero results. I don't need someone to write the code, I just need a push in the right direction. My question is what am I doing wrong? Thanks in advance.

Explanation / Answer

Look at the way you're creating the objects. First you declare the objects. private TimeOfDay start; private TimeOfDay end; But when you create them you're trying to re-declare them too, when you create an object first thing that gets executed is the class's constructor. start = new TimeOfDay start; end = new TimeOfDay end; should be something like start = new TimeOfDay(); end = new TimeOfDat();