home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_show / parking / run_parking.e < prev    next >
Text File  |  1999-06-05  |  4KB  |  108 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class RUN_PARKING
  17.    --
  18.    -- Sert de programme principal pour runr le fonctionnement d'un
  19.    -- Parking a trois levelx.
  20.    --
  21. creation {ANY}
  22.    make
  23.  
  24. feature {ANY}
  25.  
  26.    make is
  27.       local
  28.          p: PARKING;
  29.          l1, l2, l3: LEVEL;
  30.          command: COMMAND;
  31.          price: REAL;
  32.          i, value: INTEGER;
  33.       do
  34.          from
  35.             !!l1.make(14);
  36.             !!l2.make(18);
  37.             !!l3.make(25);
  38.             !!p.make(<<l1,l2,l3>>);
  39.             !!command.make;
  40.             io.put_string("Simulation du fonctionnement d'un parking.%N%N");
  41.             command.print_help_on(io);
  42.             command.get_command(io);
  43.          until
  44.             command.quit
  45.          loop
  46.             if command.arrival then
  47.                value := p.arrival;
  48.                if value > 0 then
  49.                   io.put_integer(value);
  50.                   io.put_new_line;
  51.                else
  52.                   io.put_string("Error: No More places to Park.%N");
  53.                end;
  54.             elseif command.level_count then
  55.                i := command.arg_integer;
  56.                if  i < p.lower_level then
  57.                   io.put_string("Error: Level too small.%N");
  58.                elseif i > p.upper_level then
  59.                   io.put_string("Error: Level too big.%N");
  60.                else
  61.                   io.put_integer(p.level_count(i));
  62.                   io.put_new_line;
  63.                end;
  64.             elseif command.add_time then
  65.                i := command.arg_integer;
  66.                if i <= 0 then
  67.                   io.put_string("Error: Time too small.%N");
  68.                else
  69.                   p.add_time(i);
  70.                end;
  71.             elseif command.hour_price then
  72.                price := command.arg_real;
  73.                if price <= 0 then
  74.                   io.put_string("Error: It is not Enought.%N");
  75.                else
  76.                   p.set_hour_price(price);
  77.                end;
  78.             elseif command.departure then
  79.                i := command.arg_integer;
  80.                if i <= 0 then
  81.                   io.put_string("Error: Too Small car #.%N");
  82.                else
  83.                   price := p.departure(i);
  84.                   if price < 0 then
  85.                      io.put_string("Error: this car is already outside.%N");
  86.                   else
  87.                      io.put_real(price);
  88.                      io.put_new_line;
  89.                   end;
  90.                end;
  91.             elseif command.clock then
  92.                p.clock.print_on(io);
  93.                io.put_new_line;
  94.             elseif command.count then
  95.                io.put_integer(p.count);
  96.                io.put_new_line;
  97.             elseif command.help then
  98.                command.print_help_on(io);
  99.             else
  100.                io.put_string("Error: Unkown Command.%N");
  101.             end;
  102.             command.get_command(io);
  103.          end;
  104.          io.put_string("Quit%N");
  105.       end;
  106.  
  107. end -- RUN_PARKING
  108.