-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathExercise.java
More file actions
61 lines (49 loc) · 1.82 KB
/
Exercise.java
File metadata and controls
61 lines (49 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package org.codedifferently;
// Class that represents a single exercise
public class Exercise {
// The type of exercise (ex: cardio, strength, etc.)
private ExerciseType type;
// Name of the exercise (ex: Pushups, Running)
private String name;
// Number of calories burned during the exercise
private int caloriesBurned;
// Constructor used to create a new Exercise object
public Exercise(ExerciseType type, String name, int caloriesBurned) {
this.type = type; // set exercise type
this.name = name; // set exercise name
this.caloriesBurned = caloriesBurned; // set calories burned
}
// Returns the exercise type
public ExerciseType getType() {
return type;
}
// Updates the exercise type
public void setType(ExerciseType type) {
this.type = type;
}
// Returns the name of the exercise
public String getName() {
return name;
}
// Updates the name of the exercise
public void setName(String name) {
this.name = name;
}
// Returns the number of calories burned
public int getCaloriesBurned() {
return caloriesBurned;
}
// Updates the number of calories burned
public void setCaloriesBurned(int caloriesBurned) {
this.caloriesBurned = caloriesBurned;
}
// Displays the exercise information to the console
public void displayExerciseInfo() {
System.out.println("--------------------");
System.out.println("Exercise Information");
System.out.println("Name: " + name); // print exercise name
System.out.println("Type: " + type); // print exercise type
System.out.println("Calories Burned: " + caloriesBurned); // print calories burned
System.out.println();
}
}