-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
60 lines (49 loc) · 1.76 KB
/
Main.java
File metadata and controls
60 lines (49 loc) · 1.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
/*
Title: Main.java
Name: Dylan Kapustka (Dlk190000)
Instructor: Professor Ozbirn
Course: CS 4348.001 - S21
Date: 05/01/2021
Description: Main class handles reading and parsing input file. Creates a new instance of each algorithm
*/
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args){
//Check arguments
if (args.length != 1) {
System.out.println("Error Incorrect Arguments");
System.exit(0);
}
//Declare job variables
ArrayList<myJob> jobList = new ArrayList<>();
String currJob;
//Read file
try {
FileReader fileReader = new FileReader(args[0]);
BufferedReader bufferedReader = new BufferedReader(fileReader);
//Parse file and add jobs to job list
while((currJob = bufferedReader.readLine()) != null)
{
String[] parseLine = currJob.split("\t",3);
jobList.add(new myJob(parseLine[0], Integer.parseInt(parseLine[1]), Integer.parseInt(parseLine[2])));
}
}
//Error handling
catch (FileNotFoundException ex)
{
System.out.println("Unable to open file");
}
catch (IOException e)
{
System.out.println("Error reading file");
}
//Create new instance of each scheduling algorithm, passing in job list
FCFS FCFS_scheduler = new FCFS();
FCFS_scheduler.mySchedule(jobList);
SPN SPN_scheduler = new SPN();
SPN_scheduler.mySchedule(jobList);
HRRN HRRN_scheduler = new HRRN();
HRRN_scheduler.mySchedule(jobList);
}
}