-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercisingPrograms.java
More file actions
65 lines (52 loc) · 1.37 KB
/
ExercisingPrograms.java
File metadata and controls
65 lines (52 loc) · 1.37 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
62
63
64
65
package healthcenter;
public class ExercisingPrograms {
//Programs' attributes
private double price;
private String name;
private int duration;
//empty constructor
public ExercisingPrograms() {
setPrice(10);
setName("Program");
setDuration(30);
}
//full constructor
public ExercisingPrograms(double p, String s, int m) {
setPrice(p);
setName(s);
setDuration(m);
}
//set program's price
public void setPrice(double p) {
price = p;
}
//set program's duration
public void setDuration(int m) {
duration = m;
}
//get program's price
public double getPrice() {
return price;
}
//set program's name
public void setName(String s) {
name = s;
}
//get program's name
public String getName() {
return name;
}
//get program's duration
public int getDuration() {
return duration;
}
//toString() method
public String toString() {
String message;
if(getPrice() != 0)
message = "\nThe " + getName() + " program costs " + getPrice() + "€. and lasts for " + getDuration() + " minutes.\n";
else
message = "";
return message;
}
}