home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_show / parking / command.e next >
Text File  |  1999-06-05  |  4KB  |  143 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 COMMAND
  17.    --
  18.    -- Separate Handling of Keyboard Input.
  19.    --
  20.  
  21. creation {ANY}
  22.    make
  23.  
  24. feature {ANY}
  25.  
  26.    arrival: BOOLEAN is
  27.       do
  28.          Result := (code = c_arrival)
  29.       end;
  30.  
  31.    departure: BOOLEAN is
  32.       do
  33.          Result := (code = c_departure)
  34.       end;
  35.  
  36.    level_count: BOOLEAN is
  37.       do
  38.          Result := (code = c_level_count)
  39.       end;
  40.  
  41.    hour_price: BOOLEAN is
  42.          do
  43.          Result := (code = c_hour_price)
  44.       end;
  45.  
  46.    add_time: BOOLEAN is
  47.          do
  48.          Result := (code = c_add_time)
  49.       end;
  50.  
  51.    clock: BOOLEAN is
  52.          do
  53.          Result := (code = c_clock)
  54.       end;
  55.  
  56.    quit: BOOLEAN is
  57.       do
  58.          Result := (code = c_quit)
  59.       end;
  60.  
  61.    help: BOOLEAN is
  62.       do
  63.          Result := (code = c_help)
  64.       end;
  65.  
  66.    arg_real: REAL is
  67.       do
  68.          Result := cmd.to_real;
  69.       end;
  70.  
  71.    arg_integer: INTEGER is
  72.       do
  73.          Result := cmd.to_integer;
  74.       end;
  75.  
  76.    count: BOOLEAN is
  77.       do
  78.          Result := (code = c_count)
  79.       end;
  80.  
  81. feature {ANY} -- Modifications :
  82.  
  83.    make is
  84.       do
  85.       end;
  86.  
  87.    get_command(sio: STD_INPUT_OUTPUT) is
  88.       require
  89.          sio /= Void;
  90.       local
  91.          stop: BOOLEAN;
  92.       do
  93.          sio.read_line;
  94.          cmd := sio.last_string;
  95.          from
  96.             code := ' ';
  97.             stop := (cmd.count < 1);
  98.          until
  99.             stop
  100.          loop
  101.             code := cmd @ 1;
  102.             cmd.remove(1);
  103.             stop := ((code /= ' ') and (code /= '%T')) or (cmd.count < 1)
  104.          end;
  105.       end; -- get_command
  106.  
  107.    print_help_on(sio: STD_INPUT_OUTPUT) is
  108.       require
  109.          sio /= Void;
  110.       do
  111.          sio.put_string(" Commands :N%
  112.                          % -------------------%N%
  113.                          % q        Quit%N%
  114.                          % a        Arrival of a car%N%
  115.                          % d <i>    Departure of car number <i>%N%
  116.                          % l <i>    number of car at Level <i>%N%
  117.                          % h <x>    set Hour price with <x>%N%
  118.                          % c        total Count of cars%N%
  119.                          % t <i>    add Time <i> minutes%N%
  120.                          % T        current Time%N%
  121.                          % ?        help%N");
  122.       end;
  123.  
  124. feature {COMMAND}
  125.  
  126.    c_arrival : CHARACTER is 'a';
  127.    c_departure : CHARACTER is 'd';
  128.    c_level_count : CHARACTER is 'l';
  129.    c_hour_price : CHARACTER is 'h';
  130.    c_add_time : CHARACTER is 't';
  131.    c_clock : CHARACTER is 'T';
  132.    c_quit : CHARACTER is 'q';
  133.    c_count : CHARACTER is 'c';
  134.    c_help : CHARACTER is '?';
  135.  
  136.    code : CHARACTER;
  137.  
  138. feature {NONE}
  139.  
  140.    cmd: STRING;
  141.  
  142. end -- COMMAND
  143.