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

4th time uploading this picture. it is readable. please, I can\'t use any more q

ID: 3695114 • Letter: 4

Question


4th time uploading this picture. it is readable. please, I can't use any more questions on this.

perties o Moth: private int sype -Default and standard (same nexmber nsmber parameters the mamber ot properties Both A method required to make this chass comparable. Year, Month, and Day friendl get und set methods for each private peopeny equaloO method that returns true if two objects have the exacthy values Ser o displayO method that shows the date reprenenied by this obyect in a over Triendly manner. Assume users are American citizens Then create a DayOrWeek class, which should be Date1l class's subclas.. n create a DayOfWeek class, which should be Datel class's subclass. A standard constructor with four parameter that MUST call the super class's constructor DoW: private int o o Both get and set methods for each private property o A method required to make this class comparable. . Methods: o Override equalO method of Datel class.

Explanation / Answer

############### Date1.java ##########################

public class Date1{

   protected int Year;
   private int Month;
   private int Day;
  
   public Date1(){
       Year = 0;
       Month = 0;
       Day = 0;
   }
  
   public Date1(int year, int month, int day) {
       Year = year;
       Month = month;
       Day = day;
   }

   /**
   * @return the year
   */
   public int getYear() {
       return Year;
   }

   /**
   * @return the month
   */
   public int getMonth() {
       return Month;
   }

   /**
   * @return the day
   */
   public int getDay() {
       return Day;
   }

   /**
   * @param year the year to set
   */
   public void setYear(int year) {
       Year = year;
   }

   /**
   * @param month the month to set
   */
   public void setMonth(int month) {
       Month = month;
   }

   /**
   * @param day the day to set
   */
   public void setDay(int day) {
       Day = day;
   }

   // compare method
   public int compareTo(Date1 o) {
      
       if(this.Year < o.Year)
           return -1;
       else if(this.Year > o.Year)
           return 1;
       else{
           if(this.Month < o.Month)
               return -1;
           else if(this.Month > o.Month)
               return 1;
           else{
               if(this.Day < o.Day)
                   return -1;
               else if(this.Day > o.Day)
                   return 1;
               else
                   return 0;
           }
       }
   }
  
   @Override
   public boolean equals(Object obj) {
       Date1 date1 = (Date1)obj;
      
       if(compareTo(date1) == 0)
           return true;
       else
           return false;
   }
  
   public void display(){
       System.out.println("Date (yyyy/mm/dd): "+Year+"/"+Month+"/"+Day);
   }
}

################# DayOfWeek.java ###################################

public class DayOfWeek extends Date1{
  
   private int DoW;

   /**
   * @param doW
   */
   public DayOfWeek(int Year, int Month, int Day, int doW) {
       super(Year,Month, Day);
       DoW = doW;
   }

   /**
   * @return the doW
   */
   public int getDoW() {
       return DoW;
   }

   /**
   * @param doW the doW to set
   */
   public void setDoW(int doW) {
       DoW = doW;
   }
  
   // compare method
   public int compareTo(DayOfWeek o) {
       if(this.getYear() < o.getYear())
           return -1;
       else if(this.Year > o.Year)
           return 1;
       else{
           if(this.getMonth() < o.getMonth())
               return -1;
           else if(this.getMonth() > o.getMonth())
               return 1;
           else{
               if(this.getDay() < o.getDay())
                   return -1;
               else if(this.getDay() > o.getDay())
                   return 1;
               else{
                   if(this.DoW < o.DoW)
                       return -1;
                   else if(this.DoW > o.DoW)
                       return 1;
                   else
                       return 0;
               }
           }
       }
   }
  
   @Override
   public boolean equals(Object obj) {
      
       DayOfWeek d = (DayOfWeek)obj;
       if(this.Year == d.Year &&
           this.getMonth() == d.getMonth()&&
           this.getDay() == d.getDay() &&
           this.DoW == d.DoW)
           return true;
       else
           return false;
   }
  
}

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