-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeam.java
124 lines (107 loc) · 3.56 KB
/
Team.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
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
public class Team {
public static Member addMembers() {
String Info = InputOutput.input("Name:Surname:Sex:DD/MM/YYYY");
String[] Info_input = Info.split("[:/]");
Member NewMember = new Member(Info_input[0],Info_input[1],Info_input[2].toCharArray()[0],Integer.valueOf(Info_input[3]),Integer.valueOf(Info_input[4]).intValue(),Integer.valueOf(Info_input[5]).intValue());
return NewMember;
}
public static void main(String args[]) {
InputOutput.output("========================");
InputOutput.output("Welcome to the TEAM Building system.");
InputOutput.output("========================");
int members = InputOutput.inputInt("Memebers in the team: ");
Member[] teamMembers = new Member[members];
for (int i = 0; i< members; i++) {
teamMembers[i] = addMembers();
}
InputOutput.output("Team Builder Menu:");
InputOutput.output("=======================");
InputOutput.output("1) List the team members");
InputOutput.output("2) Find the oldest member");
InputOutput.output("3) Find the youngest member");
int selection = InputOutput.inputInt("Which action do you want to perform? ");
switch (selection) {
case 1 :
listMember(teamMembers);
break;
case 2 :
findOld(teamMembers);
break;
case 3 :
findYoung(teamMembers);
break;
default:
InputOutput.output("Fause input, try again");
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
main(args);
}
}
public static void showMenu(Member[] teamMembers) {
InputOutput.output("Team Builder Menu:");
InputOutput.output("=======================");
InputOutput.output("1) List the team members");
InputOutput.output("2) Find the oldest member");
InputOutput.output("3) Find the youngest member");
int selection = InputOutput.inputInt("Which action do you want to perform? (Press 0 to exit)");
switch (selection) {
case 1 :
listMember(teamMembers);
break;
case 2 :
findOld(teamMembers);
break;
case 3 :
findYoung(teamMembers);
break;
case 0:
break;
default:
InputOutput.output("Fause input, try again");
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
showMenu(teamMembers);
}
}
/* Pretty Straight forward*/
public static void listMember(Member[] teamMembers) {
for (int i = 0; i < teamMembers.length; i++) {
InputOutput.output(teamMembers[i].toString());
}
System.out.println();
try {
Thread.sleep(3000);
}catch (InterruptedException e) {
e.printStackTrace();
}
showMenu(teamMembers);
}
public static void findOld(Member[] teamMembers) {
Member[] temp = BubbleSort.bubbleSortA(teamMembers,true);
InputOutput.output(temp[0].getName()+" "+temp[0].getSurname()+", "+"age: "+ (2018-temp[0].getYear()));
System.out.println();
try {
Thread.sleep(3000);
}catch (InterruptedException e) {
e.printStackTrace();
}
showMenu(teamMembers);
}
public static void findYoung(Member[] teamMembers) {
Member[] temp = BubbleSort.bubbleSortA(teamMembers,false);
InputOutput.output(temp[0].getName()+" "+temp[0].getSurname()+", "+"age: "+ (2018-temp[0].getYear()));
System.out.println();
try {
Thread.sleep(2000);
}catch (InterruptedException e) {
e.printStackTrace();
}
showMenu(teamMembers);
}
}