-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputAthleteInfo.java
More file actions
178 lines (131 loc) · 5.76 KB
/
InputAthleteInfo.java
File metadata and controls
178 lines (131 loc) · 5.76 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package costCalculator;
import java.util.Scanner;
public class InputAthleteInfo extends AthleteInfo{
public void acceptAthleteInput() {
System.out.println("Welcome to North Sussex Judo Athlete Training center");
Scanner scan = new Scanner(System.in);
//for athlete name input
while (true) {
System.out.println("Please enter your name");
setName(scan.nextLine());
//expression to check user input name is valid or not
String regexp = "([A-Z][a-z]+)(\\s[A-Z][a-z]+)*";
if (getName().matches(regexp)) {
break;//break out of the loop if the input is valid
} else {
System.out.println("please try again, your name is invalid!!");
}
}
while (true) {
System.out.println("In our training center, there are three training plan:'Beginner', 'Intermediate','Elite', Please Choose one!! ");
setTrainingPlan(scan.nextLine());
//expression to check the input training plan
if (getTrainingPlan().equalsIgnoreCase("Beginner") || getTrainingPlan().equalsIgnoreCase("Intermediate") || getTrainingPlan().equalsIgnoreCase("Elite")) {
break;
} else {
System.out.println("your input plan is invalid, please try again");
}
}
//for current weight input
while(true){
System.out.println("Please Enter your current weight");
boolean isDouble= false;
while(isDouble==false){
scan=new Scanner(System.in);
// expression to check the current weight input
if(scan.hasNextDouble()){
setCurrentWeight(scan.nextDouble());
isDouble=true;
}
else {
System.out.println("invalid current weight, Please try again");
isDouble=false;
}
}
if (getCurrentWeight()>=0){
break;
}
else{
System.out.println("invalid input , the current weight can't be negative");
}
}
if(getCurrentWeight() > 100.0) {
setCompWtCat("Heavyweight");
System.out.println("Heavy Weight");
} else if(getCurrentWeight() >= 90.1 && getCurrentWeight() <= 100.0) {
setCompWtCat("Light Heavy Weight");
System.out.println("Light-heavyweight");
} else if(getCurrentWeight() >= 81.1 && getCurrentWeight() <= 90.0) {
setCompWtCat("Middle Weight");
System.out.println("Middleweight");
} else if(getCurrentWeight() >= 73.1 && getCurrentWeight() <= 81.0) {
setCompWtCat("Light-middleWeight");
System.out.println("Light-middleweight");
} else if(getCurrentWeight() >= 66.1 && getCurrentWeight() <= 73.0) {
setCompWtCat("Light Weight");
System.out.println("Lightweight");
} else {
setCompWtCat("Fly Weight");
System.out.println("Flyweight");
}
//for no of competition entered this month
if(getTrainingPlan().equalsIgnoreCase("Beginner")){
setNoCompEnt(0);
}
else{
System.out.println("Enter no of competition entered this month");
while(true) {
boolean isInteger = false;
while (isInteger == false) {
scan = new Scanner(System.in);
if (scan.hasNextInt()) {
setNoCompEnt(scan.nextInt());
isInteger = true;
} else {
System.out.println("Invalid input, please enter integer value");
isInteger = false;
}
}
int noOfComp=getNoCompEnt();
if(noOfComp>=0){
break;
}
else {
System.out.println("no negative value, please try again positive value");
}
}
}
// for private coaching input
// for private coaching input
while(true){
System.out.println("Do you want private coaching or not? please say 'yes' or 'no' ");
scan=new Scanner(System.in);
String ans=scan.nextLine();
if(ans.equalsIgnoreCase("yes")){
System.out.println("Please Enter the numbers of hours for private coaching");
boolean isDouble= false;
while(isDouble==false){
scan=new Scanner(System.in);
//checking private coaching input
if(scan.hasNextDouble()){
setPrivateHourCoaching(scan.nextDouble());
isDouble=true;
}
else{
System.out.println("please enter a valid number");
isDouble=false;
}
}
double noOfHour=getPrivateHourCoaching();
if(noOfHour<0 || noOfHour>5){
System.out.println("please try again, athletes can have 5 hours of maximun private hours coaching");
}
else{ break;
}
}
else{
break;
}
}
}}
//if(ans.equalsIgnoreCase("yes")){