import sofia.micro.*;
// Virginia Tech Honor Code Pledge:
// // As a Hokie, I will conduct myself with honor and integrity at all times.// I will not lie, cheat, or steal, nor will I accept the actions of those // who do.// -- Robert Creamer (rcreamer)
//-------------------------------------------------------------------------
/**
- Represents a weekly appointment at a specified time,
- including a description.
- @author Robert Creamer (rcreamer)
- @version (2020.11.06)
- gets the hour count for appointment
- describes what type of appointment
*
*/ public class Appointment extends Actor { //~ Fields ................................................................/**
*/ private int hour; /**
*/ private String description;
// Add a field representing the hour of this appointment
// Add a field representing the description of this appointment //~ Constructor ...........................................................
// ----------------------------------------------------------
/**
- Creates a new Appointment object.
- @param h is to get numbers (0, 23)
- @param des is to describe appointment types
*
* * */ public Appointment(int h, String des) { this.hour = h; this.description = des; } //~ Methods ...............................................................
// ----------------------------------------------------------
/**
- Get the description of this appointment.
- @return This appointment's description.
*/ public String getDescription() { return this.description;
} This study source was downloaded by 100000820454130 from CourseHero.com on 04-02-2021 13:14:57 GMT -05:00
https://www.coursehero.com/file/81133402/Appointmentjava/
This study resource was shared via CourseHero.com
// ----------------------------------------------------------
/**
- Get the hour of this appointment.
- @return This appointment's hour, in military time.
*/ public int getHour() { return this.hour; }
// ----------------------------------------------------------
/**
- Set the description of this appointment.
- @param des follows apoointment type description
*/ public void setDescription(String des) { this.description = des;
}
// ----------------------------------------------------------
/**
- Set the hour of this appointment.
- @param hour The new hour for this appointment, in military
- time.
*/ public void setHour(int hour) { this.hour = hour;
}
// ----------------------------------------------------------
/**
- Set the hour of this appointment, using a more human-friendly
- string.
- @param time The new hour for this appointment, using an
- am/pm designation such as "9am" or "5pm".
*/ public void setTime(String time) { //remove the digit part out of the time in string String digits = time.substring(0, time.length() - 2);
//covert digits part to int int h = Integer.parseInt(digits); this.hour = h;
}
// ----------------------------------------------------------
/**
- Get a string representation of this appointment.
- @return A human-readable representation of this appointment
- that includes the time (in am/pm format) and the description,
- such as "11am: CS 1114". This study source was downloaded by 100000820454130 from CourseHero.com on 04-02-2021 13:14:57 GMT -05:00
https://www.coursehero.com/file/81133402/Appointmentjava/
This study resource was shared via CourseHero.com
*/ public String toString() {
//print the appointment detials String str = "Appointment at" + this.hour + "hours for" + this.description; return str;
} } This study source was downloaded by 100000820454130 from CourseHero.com on 04-02-2021 13:14:57 GMT -05:00
https://www.coursehero.com/file/81133402/Appointmentjava/
This study resource was shared via CourseHero.com