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

Java expert please help me the fix program below. Here is requirement from my pr

ID: 3844759 • Letter: J

Question

Java expert please help me the fix program below. Here is requirement from my professor: (URL: https://www.chegg.com/homework-help/questions-and-answers/java-expert-please-help-program--requirement-professor-write-following-personalcalendar-ev-q18951400 )

grading rubric

(-2)code should implement naming conventions, appropriate access control and static

10 pts per class

(-3)PersonalCalendar should accept Event

(-3)PersonalCalendar should accept Appointment

(-3)PersonalCalendar should keep content sorted by date

almost succeeds in keeping sorted

(-2)PersonalCalendar should keep content sorted by date

sorts events and appointments, but doesn't merge them

(-1)PersonalCalendar should mix Event and Appointment content sorted by date

(-2)Event should keep date of 5 ints-- year, month, day, hour, minute

(-2)Event should have int duration

(-2)Event should have String description

(-2)Event should have equals compare dates and descriptions

(-2)Event should have NO Attendees

(-2)Appointment should have date of 5 ints-- year, month, day, hour, minute

(-1)Appointment should have int duration

(-1)Appointment should have String description

(-2)Appointment should have ArrayList for attendees

(-2)Appointment should add attendees

(-1)Appointment should have equals compare dates and descriptions

(-1)Appointment should have NO Location

(-4)JUnit should test that PersonalCalendar entries are sorted

A test that works, just not JUnit

(-2)Test should be JUnit

-----------------Please help me fixed the program below follow the grading rubric-----------------

public class ScheduleRemainder implements Comparable {

   public int year;
   public int month;
   public int dayofMonth;
   public int hour;
   public int minute;
   public int durationinMinutes;

   public ScheduleRemainder(int year, int month, int dayofMonth, int hour,
           int minute, int durationinMinutes) {
       this.year = year;
       this.month = month;
       this.dayofMonth = dayofMonth;
       this.hour = hour;
       this.minute = minute;
       this.durationinMinutes = durationinMinutes;
   }

   public int hashCode() {
       final int prime = 31;
       int result = 1;
       result = prime * result + dayofMonth;
       result = prime * result + durationinMinutes;
       result = prime * result + hour;
       result = prime * result + minute;
       result = prime * result + month;
       result = prime * result + year;
       return result;
   }

   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (obj == null)
           return false;
       if (getClass() != obj.getClass())
           return false;
       ScheduleRemainder other = (ScheduleRemainder) obj;
       if (dayofMonth != other.dayofMonth)
           return false;
       if (durationinMinutes != other.durationinMinutes)
           return false;
       if (hour != other.hour)
           return false;
       if (minute != other.minute)
           return false;
       if (month != other.month)
           return false;
       if (year != other.year)
           return false;
       return true;
   }

   public int compareTo(ScheduleRemainder args) {

       if (this.year != args.year) {
           return this.year - args.year;
       } else {
           if (this.month != args.month)
               return this.month - args.year;
           else {
               if (this.dayofMonth != args.dayofMonth) {
                   return this.dayofMonth - args.dayofMonth;
               } else {
                   if (this.hour != args.hour) {
                       return this.hour - args.hour;
                   } else {
                       if (this.minute != args.minute) {
                           return this.minute - args.minute;
                       }
                   }
               }
           }
       }
       return 0;
   }

}

******************************************************************************************************


public class Event extends ScheduleRemainder{
  
   public String description;
   public String location;
  
   public Event(int year, int month, int dayofMonth, int hour, int minute,
           int durationinMinutes, String description, String location) {
       super(year, month, dayofMonth, hour, minute, durationinMinutes);
       this.description = description;
       this.location = location;
   }
   @Override
   public int hashCode() {
       final int prime = 31;
       int result = super.hashCode();
       result = prime * result
               + ((description == null) ? 0 : description.hashCode());
       result = prime * result
               + ((location == null) ? 0 : location.hashCode());
       return result;
   }
   @Override
   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (!super.equals(obj))
           return false;
       if (getClass() != obj.getClass())
           return false;
       Event other = (Event) obj;
       if (description == null) {
           if (other.description != null)
               return false;
       } else if (!description.equals(other.description))
           return false;
       if (location == null) {
           if (other.location != null)
               return false;
       } else if (!location.equals(other.location))
           return false;
       return true;
   }
   @Override
   public String toString() {
       return "Event [description=" + description + ", location=" + location
               + ", year=" + year + ", month=" + month + ", dayofMonth="
               + dayofMonth + ", hour=" + hour + ", minute=" + minute
               + ", durationinMinutes=" + durationinMinutes + "]";
   }
  
  
  

}

************************************************************************************************************************

import java.util.ArrayList;
import java.util.List;


public class Appointment extends ScheduleRemainder {
  
   public String description;
   List attendees;
   public Appointment(int year, int month, int dayofMonth, int hour,
           int minute, int durationinMinutes, String description,
           List attendes) {
       super(year, month, dayofMonth, hour, minute, durationinMinutes);
       this.description = description;
       this.attendees = new ArrayList();
   }
  
   public void addAttendees(Attendee attendee)
   {
       int count=0;
       for(Attendee a:attendees)
       {
           if(a.equals(attendee))
           {
               ++count;
           }
          
       }
       if(count==0)
       {
           attendees.add(attendee);
       }else
           System.out.println("already added");
      
   }

   @Override
   public int hashCode() {
       final int prime = 31;
       int result = super.hashCode();
       result = prime * result
               + ((attendees == null) ? 0 : attendees.hashCode());
       result = prime * result
               + ((description == null) ? 0 : description.hashCode());
       return result;
   }

   @Override
   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (!super.equals(obj))
           return false;
       if (getClass() != obj.getClass())
           return false;
       Appointment other = (Appointment) obj;
       if (attendees == null) {
           if (other.attendees != null)
               return false;
       } else if (!attendees.equals(other.attendees))
           return false;
       if (description == null) {
           if (other.description != null)
               return false;
       } else if (!description.equals(other.description))
           return false;
       return true;
   }

   @Override
   public String toString() {
       return "Appointment [description=" + description + ", attendees="
               + attendees + ", year=" + year + ", month=" + month
               + ", dayofMonth=" + dayofMonth + ", hour=" + hour + ", minute="
               + minute + ", durationinMinutes=" + durationinMinutes + "]";
   }
  
  

}

*************************************************************************************************************

public class Attendee {

   public String attendeeName;

   public Attendee(String attendeeName) {
       this.attendeeName = attendeeName;
   }

   @Override
   public int hashCode() {
       final int prime = 31;
       int result = 1;
       result = prime * result
               + ((attendeeName == null) ? 0 : attendeeName.hashCode());
       return result;
   }

   @Override
   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (obj == null)
           return false;
       if (getClass() != obj.getClass())
           return false;
       Attendee other = (Attendee) obj;
       if (attendeeName == null) {
           if (other.attendeeName != null)
               return false;
       } else if (!attendeeName.equals(other.attendeeName))
           return false;
       return true;
   }

   @Override
   public String toString() {
       return "Attendee [attendeeName=" + attendeeName + "]";
   }

}

*******************************************************************************************************************

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class PersonCalendar {

   List schedules;

   public PersonCalendar() {
       this.schedules = new ArrayList();
   }

   public void add(ScheduleRemainder r) {
       int count = 0;

       for (ScheduleRemainder remainder : schedules) {
           if (remainder.equals(r)) {
               ++count;
           }
       }

       if (count == 0) {
           schedules.add(r);
       } else
           System.out.println("already added the event");

   }

   public void showList(List schedules) {
       for (ScheduleRemainder remainder : schedules) {
           System.out.println(remainder);
       }
   }

   public void sortedByDate(List schedules) {
       Collections.sort(schedules);

       for (ScheduleRemainder remainder : schedules) {
           System.out.println(remainder);
       }
   }

   public static void main(String[] args) {

       PersonCalendar calendar = new PersonCalendar();

       ScheduleRemainder r = new Event(2017, 04, 25, 10, 36, 60,
               "success meet", "new york");

       calendar.add(r);
       List attendees = new ArrayList();

       Attendee a = new Attendee("david");
       Attendee a1 = new Attendee("mark");
       Attendee a2 = new Attendee("smith");
       Attendee a3 = new Attendee("alice");
       attendees.add(a);
       attendees.add(a1);
       attendees.add(a2);
       attendees.add(a3);
       ScheduleRemainder r1 = new Appointment(2015, 11, 02, 05, 30, 30,
               "private appointment", attendees);

       calendar.add(r1);
       System.out.println("before sorting by date");

       calendar.showList(calendar.schedules);

       System.out
               .println("***************************************************************");
       System.out.println("after sorting by date");
       calendar.sortedByDate(calendar.schedules);

   }
}

Explanation / Answer

import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Event extends ScheduleRemainder{
  
public String description;
public String location;
  
public Event(int year, int month, int dayofMonth, int hour, int minute,
int durationinMinutes, String description, String location) {
super(year, month, dayofMonth, hour, minute, durationinMinutes);
this.description = description;
this.location = location;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result
+ ((description == null) ? 0 : description.hashCode());
result = prime * result
+ ((location == null) ? 0 : location.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
Event other = (Event) obj;
if (description == null) {
if (other.description != null)
return false;
} else if (!description.equals(other.description))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
return true;
}
@Override
public String toString() {
return "Event [description=" + description + ", location=" + location
+ ", year=" + year + ", month=" + month + ", dayofMonth="
+ dayofMonth + ", hour=" + hour + ", minute=" + minute
+ ", durationinMinutes=" + durationinMinutes + "]";
}
  
  
  
}
@SuppressWarnings("unchecked")
class ScheduleRemainder implements Comparable {
public int year;
public int month;
public int dayofMonth;
public int hour;
public int minute;
public int durationinMinutes;
public ScheduleRemainder(int year, int month, int dayofMonth, int hour,
int minute, int durationinMinutes) {
this.year = year;
this.month = month;
this.dayofMonth = dayofMonth;
this.hour = hour;
this.minute = minute;
this.durationinMinutes = durationinMinutes;
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + dayofMonth;
result = prime * result + durationinMinutes;
result = prime * result + hour;
result = prime * result + minute;
result = prime * result + month;
result = prime * result + year;
return result;
}
public int compareTo(Object obj){
   return 0;
}
public int compareTo(ScheduleRemainder args) {
if (this.year != args.year) {
return this.year - args.year;
} else {
if (this.month != args.month)
return this.month - args.year;
else {
if (this.dayofMonth != args.dayofMonth) {
return this.dayofMonth - args.dayofMonth;
} else {
if (this.hour != args.hour) {
return this.hour - args.hour;
} else {
if (this.minute != args.minute) {
return this.minute - args.minute;
}
}
}
}
}
return 0;
}
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ScheduleRemainder other = (ScheduleRemainder) obj;
if (dayofMonth != other.dayofMonth)
return false;
if (durationinMinutes != other.durationinMinutes)
return false;
if (hour != other.hour)
return false;
if (minute != other.minute)
return false;
if (month != other.month)
return false;
if (year != other.year)
return false;
return true;
}
}

class Appointment extends ScheduleRemainder {
  
public String description;
List<Attendee> attendees;
public Appointment(int year, int month, int dayofMonth, int hour,
int minute, int durationinMinutes, String description,
List<Attendee> attendes) {
super(year, month, dayofMonth, hour, minute, durationinMinutes);
this.description = description;
this.attendees = new ArrayList<Attendee>();
}
  
public void addAttendees(Attendee attendee)
{
int count=0;
for(Attendee a:attendees)
{
if(a.equals(attendee))
{
++count;
}
  
}
if(count==0)
{
attendees.add(attendee);
}else
System.out.println("already added");
  
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result
+ ((attendees == null) ? 0 : attendees.hashCode());
result = prime * result
+ ((description == null) ? 0 : description.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
Appointment other = (Appointment) obj;
if (attendees == null) {
if (other.attendees != null)
return false;
} else if (!attendees.equals(other.attendees))
return false;
if (description == null) {
if (other.description != null)
return false;
} else if (!description.equals(other.description))
return false;
return true;
}
@Override
public String toString() {
return "Appointment [description=" + description + ", attendees="
+ attendees + ", year=" + year + ", month=" + month
+ ", dayofMonth=" + dayofMonth + ", hour=" + hour + ", minute="
+ minute + ", durationinMinutes=" + durationinMinutes + "]";
}
  
  
}

class Attendee {
public String attendeeName;
public Attendee(String attendeeName) {
this.attendeeName = attendeeName;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((attendeeName == null) ? 0 : attendeeName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Attendee other = (Attendee) obj;
if (attendeeName == null) {
if (other.attendeeName != null)
return false;
} else if (!attendeeName.equals(other.attendeeName))
return false;
return true;
}
@Override
public String toString() {
return "Attendee [attendeeName=" + attendeeName + "]";
}
}

class PersonCalendar {
List<ScheduleRemainder> schedules;
public PersonCalendar() {
this.schedules = new ArrayList<ScheduleRemainder>();
}
public void add(ScheduleRemainder r) {
int count = 0;
for (ScheduleRemainder remainder : schedules) {
if (remainder.equals(r)) {
++count;
}
}
if (count == 0) {
schedules.add(r);
} else
System.out.println("already added the event");
}
public void showList(List<ScheduleRemainder> schedules) {
for (ScheduleRemainder remainder : schedules) {
System.out.println(remainder);
}
}
public void sortedByDate(List<ScheduleRemainder> schedules) {
Collections.sort(schedules);
for (ScheduleRemainder remainder : schedules) {
System.out.println(remainder);
}
}
public static void main(String[] args) {
PersonCalendar calendar = new PersonCalendar();
ScheduleRemainder r = new Event(2017, 04, 25, 10, 36, 60,
"success meet", "new york");
calendar.add(r);
List<Attendee> attendees = new ArrayList<Attendee>();
Attendee a = new Attendee("david");
Attendee a1 = new Attendee("mark");
Attendee a2 = new Attendee("smith");
Attendee a3 = new Attendee("alice");
attendees.add(a);
attendees.add(a1);
attendees.add(a2);
attendees.add(a3);
ScheduleRemainder r1 = new Appointment(2015, 11, 02, 05, 30, 30,
"private appointment", attendees);
calendar.add(r1);
System.out.println("before sorting by date");
calendar.showList(calendar.schedules);
System.out
.println("***************************************************************");
System.out.println("after sorting by date");
calendar.sortedByDate(calendar.schedules);
}
}

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