-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
460 additions
and
306 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...thTrack/app/src/main/java/com/example/healthtrack/model/CompletionTimestampDecorator.java
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,23 @@ | ||
package com.example.healthtrack.model; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public class CompletionTimestampDecorator extends WorkoutDecorator { | ||
private LocalDateTime completionTimestamp; | ||
|
||
public CompletionTimestampDecorator(WorkoutComponent workout) { | ||
super(workout); | ||
} | ||
|
||
public void markCompleted() { | ||
completionTimestamp = LocalDateTime.now(); | ||
} | ||
|
||
@Override | ||
public void perform() { | ||
super.perform(); | ||
if (completionTimestamp != null) { | ||
System.out.println("Workout completed at: " + completionTimestamp); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...thTrack/app/src/main/java/com/example/healthtrack/model/ParticipantTrackingDecorator.java
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,19 @@ | ||
package com.example.healthtrack.model; | ||
|
||
public class ParticipantTrackingDecorator extends WorkoutDecorator { | ||
private int participants; | ||
|
||
public ParticipantTrackingDecorator(WorkoutComponent workout) { | ||
super(workout); | ||
} | ||
|
||
public void addParticipant() { | ||
participants++; | ||
} | ||
|
||
@Override | ||
public void perform() { | ||
super.perform(); | ||
System.out.println("Number of participants: " + participants); | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
HealthTrack/app/src/main/java/com/example/healthtrack/model/SortingContext.java
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package com.example.healthtrack.model; | ||
|
||
import com.example.healthtrack.model.SortingStrategy; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class SortingContext { | ||
public static ArrayList<WorkoutPlan> filter(SortingStrategy strategy, ArrayList<WorkoutPlan> list) { | ||
public static ArrayList<WorkoutPlan> filter(SortingStrategy strategy, | ||
ArrayList<WorkoutPlan> list) { | ||
return strategy.sort(list); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
HealthTrack/app/src/main/java/com/example/healthtrack/model/WorkoutComponent.java
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,5 @@ | ||
package com.example.healthtrack.model; | ||
|
||
public interface WorkoutComponent { | ||
void perform(); | ||
} |
14 changes: 14 additions & 0 deletions
14
HealthTrack/app/src/main/java/com/example/healthtrack/model/WorkoutDecorator.java
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,14 @@ | ||
package com.example.healthtrack.model; | ||
|
||
public abstract class WorkoutDecorator implements WorkoutComponent { | ||
protected WorkoutComponent decoratedWorkout; | ||
|
||
public WorkoutDecorator(WorkoutComponent workout) { | ||
this.decoratedWorkout = workout; | ||
} | ||
|
||
@Override | ||
public void perform() { | ||
decoratedWorkout.perform(); | ||
} | ||
} |
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
Oops, something went wrong.