-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrew.java
More file actions
executable file
·42 lines (37 loc) · 1.12 KB
/
Copy pathCrew.java
File metadata and controls
executable file
·42 lines (37 loc) · 1.12 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
import java.util.*;
class Crew {
ArrayList<CrewMember> crewList = new ArrayList<CrewMember>();
UserInterface ui = new UserInterface();
Scanner keyboard = new Scanner(System.in);
String crewName;
int crewAge;
int[] crewMakeup = {0, 0, 0, 0, 1}; // engr, sci, com, pilot, capt
public Crew() {
}
public void modifyCrew(int whichCrew, int num) {
crewMakeup[whichCrew] = crewMakeup[whichCrew] + num;
}
public int getTotalCrew() {
int sum = 0;
for(int num : crewMakeup) {
sum = sum+num;
}
return sum;
}
public void printCrewList() {
ui.println("\nYou currently have the following in your crew.");
ui.println(crewMakeup[0] + " Engineers");
ui.println(crewMakeup[1] + " Scientists");
ui.println(crewMakeup[2] + " Communications Officers");
ui.println(crewMakeup[3] + " Pilots");
ui.println(crewMakeup[4] + " Captain");
}
public void createCrew(int capacity){
ui.println("Please type in your crewmates' names.");
for(int i=0; i<capacity; i++) {
crewName = keyboard.next();
CrewMember person = new CrewMember(crewName, 45, CrewMember.occupation.ENGINEER);
crewList.add(person);
}
}
}