-
Notifications
You must be signed in to change notification settings - Fork 0
/
Course.java
38 lines (32 loc) · 847 Bytes
/
Course.java
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
import java.lang.StringBuilder;
public class Course {
private String name;
private int[] holes;
private int coursePar;
Course(String n, int[] h) {
this.name = n;
this.holes = h;
}
public String getCourseName() {
return this.name;
}
public int getHolePar(int h) {
return this.coursePar;
}
public int getCoursePar() {
// System.out.println(holes.length);
for (int i = 0; i < holes.length; i++) {
coursePar += holes[i];
// System.out.print(coursePar + " ");
}
return this.coursePar;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (int h : holes) {
sb.append(" " + h);
}
return sb + " " + " Par: " + getCoursePar();
}
}