Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package aufg_74;
- public class Time {
- private int hour;
- private int minutes;
- //Aufgabenstellung beachten
- Time(int h, int m){
- this.hour = h;
- this.minutes = m;
- }
- //bleibt unberuehrt
- int getHour(){
- return hour;
- }
- //bleibt unberuehrt
- int getMinutes(){
- return minutes;
- }
- //Aufgabenstellung beachten
- int timeInMinutesFromZero(){
- int min = this.minutes + (this.hour * 60);
- return min;
- }
- //Aufgabenstellung beachten
- boolean isSameTimeAs(Time a){
- if(this.hour == a.hour && this.minutes == a.minutes)
- return true;
- else
- return false;
- }
- //Aufgabenstellung beachten
- boolean isLaterThan(Time a){
- if(this.hour>a.hour ||this.hour == a.hour && this.minutes >a.minutes)
- return true;
- else
- return false;
- }
- //Aufgabenstellung beachten
- Time timeInTimeFormat(int min){
- int a = min/60;
- int erg = a * 60;
- int b = min - erg;
- return new Time(a,b);
- }
- //Aufgabenstellung beachten
- int distanceInMinTo(Time a){
- int i = this.timeInMinutesFromZero();
- int j = a.timeInMinutesFromZero();
- if (i>=j)
- return i-j;
- else
- return j-i;
- }
- //Aufgabenstellung beachten
- Time addDuration(int minutes){
- int q = this.timeInMinutesFromZero();
- int erg = q+minutes;
- Time t = timeInTimeFormat(erg);
- this.hour = t.hour;
- this.minutes = t.minutes;
- return this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement