-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrowdOrganizerApp.java
More file actions
63 lines (46 loc) · 1.42 KB
/
CrowdOrganizerApp.java
File metadata and controls
63 lines (46 loc) · 1.42 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
/*
* Assignment 4 priority queue
* Written By Aron Lawrence
* Crowd organizer App
* Main program, reads events file
*
*/
package edu.wmich.cs3310.A4;
import java.io.*;
import java.util.Scanner;
public class CrowdOrganizerApp {
//************Main driver of the program********************8
public static void main(String[] args) throws IOException {
String logFile = "Log.txt";
String startFile = "Lineat6Am.csv";
BufferedWriter log = new BufferedWriter(new FileWriter(logFile));
log.write(">>> program starting \n");
File events = new File("Events.txt");
Scanner s = new Scanner(events);
CustomerPrQ prQ = new CustomerPrQ(log);
readFile(startFile, s, prQ);
s.close();
log.write(">>> program terminating");
log.close();
}
// **************reads all events and calls proper methods********
private static void readFile(String startFile, Scanner s, CustomerPrQ prQ)
throws IOException {
String[] data;
while (s.hasNextLine()) {
String inLine = s.nextLine();
if (!inLine.startsWith("//")) {
data = inLine.split(",");
if (data[0].toLowerCase().startsWith("o")) {
prQ.arrangeCustomerq(startFile);
} else if (data[0].toLowerCase().startsWith("s")) {
prQ.serveACustomer();
} else if (data[0].toLowerCase().startsWith("n")) {
prQ.addCustomerToQ(data);
} else if (data[0].toLowerCase().startsWith("c")) {
prQ.serveRemainingCustomers();
}
}
}
}
}