- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.java
More file actions
Latest commit
90 lines (64 loc) · 1.47 KB
/
Copy pathInput.java
File metadata and controls
90 lines (64 loc) · 1.47 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
importjava.io.File;
importjava.io.FileOutputStream;
importjava.io.PrintWriter;
importjava.util.Scanner;
importjava.util.Queue;
importjava.util.LinkedList;
publicclassInput
{ publicQueue<Job> jobs;
publicintcount;
intmin;
intmax;
inttotal;
intn; // number of jobs
publicInput()
{ jobs= newLinkedList<Job>();
count= 0;
min= 256;
max= 0;
total= 0;
n= (int)((Math.random()*(500 - 100) + 100)); }
publicJobgenerateJob()
{ intid= count++;
intecu= (int)((Math.random()*(512 - 16) + 16));
intjobSize= (int)((Math.random()*(256 - 16) + 16));
if(jobSize < min)
min= jobSize;
if(max < jobSize)
max= jobSize;
total += jobSize;
Jobobj= newJob(id, ecu, jobSize);
returnobj; }
publicvoidgenerateInput()
{ Filef= newFile("Jobs.txt");
FileOutputStreamfOut;
PrintWriterwriter;
try
{ fOut = newFileOutputStream(f);
writer= newPrintWriter(fOut);
Jobobj= null;
for(inti= 0; i < n; i++)
{ obj= generateJob();
writer.println(obj.jID + "\t" + obj.ECU + "\t" + obj.jobSize + "\n"); }
writer.close();
fOut.close(); }
catch (Exceptione)
{ e.getMessage(); } }
publicvoidfillJQueue()
{ Filef= newFile("Jobs.txt");
Scannerinput;
try
{ input= newScanner(f);
Jobobj;
intid;
intecu;
intsize;
while(input.hasNext())
{ id= input.nextInt();
ecu= input.nextInt();
size= input.nextInt();
obj= newJob(id, ecu, size);
jobs.add(obj); }
input.close(); }
catch (Exceptione)
{ e.getMessage(); } } }