Repository navigation
Expand file tree
/
Copy pathPerformanceScheduler.java
More file actions
157 lines (132 loc) · 6.22 KB
/
Copy pathPerformanceScheduler.java
File metadata and controls
157 lines (132 loc) · 6.22 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
/*
PerformanceScheduler
Main program that runs based off of PerformanceNode and PerformanceList.
Takes user input and creates a "performance schedule".
*/
import java.util.Scanner;
public class PerformanceScheduler {
public static void main(String[] args) throws Exception {
Boolean quit = false;
Scanner input;
String userInput;
PerformanceList schedule = new PerformanceList();
System.out.println("Welcome to Performance Scheduler");
while(!quit){
System.out.println("Choose an option: ");
System.out.println("A: Add performance");
// System.out.println("B: Move current node backward");
System.out.println("C: Display current node");
System.out.println("D: Display all nodes");
// System.out.println("F: Move current node forward");
// System.out.println("I: Insert after current node");
System.out.println("J: Jump to position ");
System.out.println("R: Remove current node");
System.out.println("Q: Exit");
input = new Scanner(System.in);
userInput = input.nextLine().toLowerCase();
String performanceName;
String leadPerformer;
int totalParticipants;
int performanceDuration;
int startTime;
int position;
switch(userInput){
case "a": // Add to end
// Get perf name
System.out.println("Add" + '\n' + "Name of performance?");
input = new Scanner(System.in);
performanceName = input.nextLine();
// Get lead perf
System.out.println("Name of lead performer: ");
input = new Scanner(System.in);
leadPerformer = input.nextLine();
// Get total participants
System.out.println("Total participants?");
input = new Scanner(System.in);
totalParticipants = input.nextInt();
// Get duration
System.out.println("Duration of performance?");
input = new Scanner(System.in);
performanceDuration = input.nextInt();
// Get start time
System.out.println("Start time:");
input = new Scanner(System.in);
startTime = input.nextInt();
schedule.addToEnd(new PerformanceNode(performanceName, leadPerformer, totalParticipants, performanceDuration, startTime));
schedule.setHead(schedule.mergeSort(schedule.getHead()));
break;
// case "b": // Move current node backward
// try{
// if(schedule.moveCursorBackward()) System.out.println("Moved cursor backwards.");
// }
// catch(Exception e){
// System.out.println("Cannot move backwards");
// }
case "c": // Display current node
schedule.displayCurrentPerformance();
break;
case "d": // Display all nodes
schedule.displayAllNodes();
break;
// case "f": // Move current node forward
// try{
// if(schedule.moveCursorForward()) System.out.println("Moved cursor forwards.");
// }
// catch(Exception e){
// System.out.println("Cannot move forward");
// }
// break;
// case "i": // Insert after current node
//
// System.out.println("Add to end" + '\n' + "Name of performance?");
//
// input = new Scanner(System.in);
// performanceName = input.nextLine();
//
// // Get lead perf
// System.out.println("Name of lead performer: ");
// input = new Scanner(System.in);
// leadPerformer = input.nextLine();
//
// // Get total participants
// System.out.println("Total participants?");
// input = new Scanner(System.in);
// totalParticipants = input.nextInt();
//
// // Get duration
// System.out.println("Duration of performance?");
// input = new Scanner(System.in);
// performanceDuration = input.nextInt();
//
// // Get start time
// System.out.println("Start time:");
// input = new Scanner(System.in);
// startTime = input.nextInt();
//
// schedule.addAfterCurrent(new PerformanceNode(performanceName, leadPerformer, totalParticipants, performanceDuration, startTime));
// schedule.setHead(schedule.mergeSort(schedule.getHead()));
// break;
case "j": // Jump to position
System.out.println("Position?");
input = new Scanner(System.in);
position = input.nextInt();
if(schedule.jumpToPosition(position)) System.out.println("Jumped to position " + position + ".");
else System.out.println("Could not jump to position " + position + ".");
break;
case "r": // Remove current node
if(schedule.removeCurrentNode()) {
System.out.println("Removed");
schedule.setHead(schedule.mergeSort(schedule.getHead()));
}
else System.out.println("Could not remove or was only node");
break;
case "q":
quit = true;
break;
default:
System.out.println("Invalid input.");
break;
}
}
}
}