PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/language/unclassified/uw/aux_uw01extra_io.e

http://github.com/tybor/Liberty
Specman e | 104 lines | 72 code | 10 blank | 22 comment | 2 complexity | 63129c633d445053e77937dc14597c3c MD5 | raw file
  1note
  2   description:
  3      "extended I/O"
  4   status:
  5      "See notice at end of class"
  6   author:
  7      "Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>"
  8   version:
  9      "$Revision$"
 10   last_modification:
 11      "$Date$"
 12class AUX_UW01EXTRA_IO
 13
 14create {ANY}
 15   make
 16
 17feature {ANY}
 18   make
 19         -- make new object
 20      do
 21         create {AUX_UW01PREFERRED_LANGUAGE} language
 22      end
 23
 24feature {ANY} -- Input
 25   read_string (prompt: STRING)
 26         -- print `prompt' and get a string
 27      require
 28         valid_prompt: prompt /= Void
 29      do
 30         io.put_string(prompt)
 31         io.read_line
 32         last_string := io.last_string
 33         last_string.right_adjust
 34         last_string.left_adjust
 35      ensure
 36         last_string /= Void
 37      end
 38
 39   read_yes_no (prompt: STRING)
 40         -- print `prompt' and get a string to
 41         -- `last_string' and also set `last_boolean'
 42      require
 43         valid_prompt: prompt /= Void
 44      local
 45         input: CHARACTER
 46      do
 47         from
 48         until
 49            input = language.yes_character or else input = language.no_character
 50         loop
 51            read_string(prompt)
 52            if last_string.count > 0 then
 53               input := last_string.item(1)
 54            end
 55         end
 56         last_boolean := input = language.yes_character
 57      ensure
 58         last_string /= Void
 59      end -- read_string
 60
 61   last_string: STRING
 62
 63   last_boolean: BOOLEAN
 64
 65feature {ANY} -- Output
 66   print_multi (objects: ARRAY[STRING])
 67         -- print all elements in `objects' as string
 68      local
 69         i: INTEGER
 70      do
 71         from
 72            i := objects.lower
 73         until
 74            i > objects.upper
 75         loop
 76            io.put_string(objects.item(i).out)
 77            i := i + 1
 78         end
 79      end
 80
 81feature {}
 82   language: AUX_UW01LANGUAGE -- language to use
 83
 84invariant
 85   good_language: language /= Void
 86
 87end -- class AUX_UW01EXTRA_IO
 88-- Copyright (C) 1998-2017: by Ulrich Windl
 89-- Copyright (C) 1998-2017: by Klinikum der Universit´┐Żt Regensburg,
 90--      D-93042 Regensburg
 91--
 92--  This program is free software; you can redistribute it and/or modify
 93--  it under the terms of the GNU General Public License as published by
 94--  the Free Software Foundation; either version 2 of the License, or
 95--  (at your option) any later version.
 96--
 97--  This program is distributed in the hope that it will be useful,
 98--  but WITHOUT ANY WARRANTY; without even the implied warranty of
 99--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
100--  GNU General Public License for more details.
101--
102--  You should have received a copy of the GNU General Public License
103--  along with this program; if not, write to the Free Software
104--  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA