File: run_parking.e

package info (click to toggle)
smarteiffel 1.1-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 12,288 kB
  • ctags: 40,785
  • sloc: ansic: 35,791; lisp: 4,036; sh: 1,783; java: 895; ruby: 613; python: 209; makefile: 115; csh: 78; cpp: 50
file content (87 lines) | stat: -rw-r--r-- 2,792 bytes parent folder | download | duplicates (2)
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
class RUN_PARKING
   --
   -- Main loop to run the PARKING example.
   --
creation make

feature {NONE}

   make is
      local
         p: PARKING; level1, level2, level3: LEVEL
         command: COMMAND; price: REAL; i, value: INTEGER
      do
         from
            !!level1.make(14)
            !!level2.make(18)
            !!level3.make(25)
            !!p.make(<<level1,level2,level3>>)
            !!command.make
            io.put_string("Parking simulation.%N%N")
            command.print_help_on(io)
            command.get_command(io)
         until
            command.quit
         loop
            if command.arrival then
               value := p.arrival
               if value > 0 then
                  io.put_integer(value)
                  io.put_new_line
               else
                  io.put_string("Error: No more places to park.%N")
               end
            elseif command.level_count then
               i := command.arg_integer
               if  i < p.lower_level then
                  io.put_string("Error: Level too small.%N")
               elseif i > p.upper_level then
                  io.put_string("Error: Level too big.%N")
               else
                  io.put_integer(p.level_count(i))
                  io.put_new_line
               end
            elseif command.add_time then
               i := command.arg_integer
               if i <= 0 then
                  io.put_string("Error: Time too small.%N")
               else
                  p.add_time(i)
               end
            elseif command.hour_price then
               price := command.arg_real
               if price <= 0 then
                  io.put_string("Error: It is not Enought.%N")
               else
                  p.set_hour_price(price)
               end
            elseif command.departure then
               i := command.arg_integer
               if i <= 0 then
                  io.put_string("Error: Too Small car #.%N")
               else
                  price := p.departure(i)
                  if price < 0 then
                     io.put_string("Error: this car is already outside.%N")
                  else
                     io.put_real(price)
                     io.put_new_line
                  end
               end
            elseif command.clock then
               p.clock.display_on(io)
               io.put_new_line
            elseif command.count then
               io.put_integer(p.count)
               io.put_new_line
            elseif command.help then
               command.print_help_on(io)
            else
               io.put_string("Error: Unknown Command.%N")
            end
            command.get_command(io)
         end
         io.put_string("Quit%N")
      end

end -- RUN_PARKING