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
from network import Process, Machine, Network
 
if __name__ == '__main__':
    p = Process('aProcess', 1)
    p2 = Process('aProcess2', 2)
    p3 = Process('aProcess3', 3)
    p4 = Process('aProcess4', 4)
    print(p)
    print(p2)
    print(p3)
    print(p4)
 
    ''' Uncomment after writing Machine:
    m = Machine('aMachine', 100)
    m2 = Machine('aMachine2', 200)
    print(m.availableMemory()) #should output 100
    print(m2.availableMemory()) #should output 200
    m.addProcess(p)
    m2.addProcess(p2)
    print(m.availableMemory()) #should output 99
    print(m2.availableMemory()) #should output 198
    m.addProcess(p3)
    m2.addProcess(p4)
    print(m.availableMemory()) #should output 96
    print(m2.availableMemory()) #should output 194
    print(m)
    print(m2)
    '''
 
    ''' Uncomment after writing Network
    n = Network()
    m = Machine('aMachine', 100) #This makes m empty again by reconstructing it
    m2 = Machine('aMachine2', 200) #same with m2
    n.addMachine(m)
    n.addMachine(m2)
    print(n) #Should have two machines, no processes
    n.addProcess(p)
    n.addProcess(p2)
    n.addProcess(p3)
    n.addProcess(p4)
    print(n) #Should have put all four processes with machine2
 
    n = Network() #makes n empty again by reconstructing it
    m = Machine('aMachine', 102) #This makes m empty again by reconstructing it
    m2 = Machine('aMachine2', 100) #same with m2 - but they have different sizes!
    n.addMachine(m)
    n.addMachine(m2)
    n.addProcess(p)
    n.addProcess(p2)
    n.addProcess(p3)
    n.addProcess(p4)
    print(n) #Should have three processes in m and one in m2
    '''