-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: preparing inheritance, polymorphism and encapsulation
Took 1 hour 4 minutes
- Loading branch information
Showing
8 changed files
with
160 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export class Meeting { | ||
startTime: Date | ||
endTime: Date | ||
|
||
constructor(startTime: Date, endTime: Date) { | ||
this.startTime = startTime | ||
this.endTime = endTime | ||
} | ||
|
||
getStartTime(): Date { | ||
return this.startTime | ||
} | ||
|
||
getEndTime(): Date { | ||
return this.endTime | ||
} | ||
|
||
getDuration(): number { | ||
return (this.endTime.getTime() - this.startTime.getTime()) / 1000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export class Member { | ||
readonly id: string | ||
name: string | ||
username: string | ||
email: string | ||
profile_picture_url: string | ||
|
||
constructor(id: string, name: string, username: string, email: string, profile_picture_url: string) { | ||
this.id = id | ||
this.name = name | ||
this.username = username | ||
this.email = email | ||
this.profile_picture_url = profile_picture_url | ||
} | ||
|
||
getId() { | ||
return this.id | ||
} | ||
|
||
getName() { | ||
return this.name | ||
} | ||
|
||
getUsername() { | ||
return this.username | ||
} | ||
|
||
getEmail() { | ||
return this.email | ||
} | ||
|
||
getProfilePictureUrl() { | ||
return this.profile_picture_url | ||
} | ||
|
||
getInfo() { | ||
return `Member: ${this.name}, ${this.email}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Member } from '@/models/Member' | ||
|
||
export class Trainer extends Member { | ||
constructor(data: Trainer | any) { | ||
super(data.id, data.name, data.username, data.email, data.profile_picture_url) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Meeting } from '@/models/Meeting' | ||
|
||
export class TrainingMeeting extends Meeting { | ||
userID: string | ||
trainerID: string | ||
|
||
constructor(startTime: Date, endTime: Date, userID: string, trainerID: string) { | ||
super(startTime, endTime) | ||
this.userID = userID | ||
this.trainerID = trainerID | ||
} | ||
|
||
getUserID(): string { | ||
return this.userID | ||
} | ||
|
||
getTrainerID(): string { | ||
return this.trainerID | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Member } from '@/models/Member' | ||
|
||
export class User extends Member { | ||
private selected_trainer_id: string | ||
private subscription_expiration_date: string | ||
private meetings: { | ||
id: string; | ||
userId: string; | ||
trainerID: string; | ||
startTime: Date; | ||
endTime: Date; | ||
}[] | ||
|
||
constructor(data: User | any) { | ||
super(data.id, data.name, data.email, data.email, data.profile_picture_url) | ||
this.selected_trainer_id = data.selected_trainer_id | ||
this.subscription_expiration_date = data.subscription_expiration_date | ||
this.meetings = data.meetings | ||
} | ||
|
||
getSelectedTrainerId() { | ||
return this.selected_trainer_id | ||
} | ||
|
||
setSelectTrainerId(trainerId: string) { | ||
this.selected_trainer_id = trainerId | ||
} | ||
|
||
getSubscriptionExpirationDate() { | ||
return this.subscription_expiration_date | ||
} | ||
|
||
setSubscriptionExpirationDate(date: string) { | ||
this.subscription_expiration_date = date | ||
} | ||
|
||
getMeetings() { | ||
return this.meetings | ||
} | ||
|
||
setMeetings(meetings: { | ||
id: string; | ||
userId: string; | ||
trainerID: string; | ||
startTime: Date; | ||
endTime: Date; | ||
}[]) { | ||
this.meetings = meetings | ||
} | ||
|
||
getInfo() { | ||
return `User: ${this.name}, ${this.email}, Trainer ID: ${this.selected_trainer_id}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters