sugar
Class Sys

java.lang.Object
  extended by sugar.Sys

public class Sys
extends java.lang.Object

This class enables simple data entry from console ( System.in ) for Strings, double and integer numbers.


Constructor Summary
Sys()
           
 
Method Summary
static boolean askStop(java.lang.String query)
          The method reads one input line.
static java.lang.String getByeMsg()
          Gets end of input message.
static double getDouble(java.lang.String s)
          The method reads one number from string.
static boolean getEnd()
          The method gives end status.
static boolean getError()
          Indicates whether error condition is raised and reset it to false.
static java.lang.String getLast()
          Get last processed element.
static java.lang.String getState()
           
static void main(java.lang.String[] args)
           
static void p(boolean b)
          Print overloaded methods
static void p(double d)
           
static void p(double d, int fract)
           
static void p(float f)
           
static void p(char c)
           
static void p(char[] s)
           
static void p(int i)
           
static void p(long l)
           
static void p(java.lang.Object o)
           
static void p(java.lang.String s)
           
static void pln()
          Print next line overloaded methods
static void pln(boolean b)
           
static void pln(double d)
           
static void pln(double d, int fract)
           
static void pln(float f)
           
static void pln(char c)
           
static void pln(char[] s)
           
static void pln(int i)
           
static void pln(long l)
           
static void pln(java.lang.Object o)
           
static void pln(java.lang.String s)
           
static double readDouble()
          The method reads one number in one input line.
static char readChar()
          Read one character
static int readInt()
          The method reads one number in one input line.
static java.lang.String readLine()
          The method reads one input line.
static java.lang.String readWord()
          Read one word ie. continuous sequence of letters
static void setByeMsg(java.lang.String msg)
          Sets end of input message.
static void setEnd(boolean e)
          The method sets end status.
static void setInputData(java.lang.String s)
           
static void sleep(long msec)
          Sleeps program for msec milisecond
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sys

public Sys()
Method Detail

readWord

public static java.lang.String readWord()
Read one word ie. continuous sequence of letters

Returns:
word or zero length string on end.

readChar

public static char readChar()
Read one character

Returns:
one character or blank (on end) or '\n' (on empty buffer)

readLine

public static java.lang.String readLine()
The method reads one input line. If line equals bye string end condition is raised. Prompt is eventually printed.

Returns:
string (without enter character).

readDouble

public static double readDouble()
The method reads one number in one input line. If line equals bye string end condition is raised. Prompt is eventually printed. If input is bye message 0 is returned and end condition is raised. If input is not of form of number error condition is raised and NaN is returned. Entered number can be preceded or followed by blanks and tabs.

Returns:
double.

readInt

public static int readInt()
The method reads one number in one input line. If line equals bye string end condition is raised. Prompt is eventually printed. If input is bye message, 0 is returned and end condition is raised. If input does not represent integer, ie. does not to int, its fraction part is not zero, error condition is raised. Entered number can be preceded or followed by blanks and tabs.

Returns:
integer part of entered number or 0 on bye.

p

public static void p(boolean b)
Print overloaded methods


p

public static void p(char c)

p

public static void p(char[] s)

p

public static void p(double d)

p

public static void p(float f)

p

public static void p(int i)

p

public static void p(long l)

p

public static void p(java.lang.Object o)

p

public static void p(double d,
                     int fract)

p

public static void p(java.lang.String s)

pln

public static void pln()
Print next line overloaded methods


pln

public static void pln(boolean b)

pln

public static void pln(char c)

pln

public static void pln(char[] s)

pln

public static void pln(double d)

pln

public static void pln(float f)

pln

public static void pln(int i)

pln

public static void pln(long l)

pln

public static void pln(java.lang.Object o)

pln

public static void pln(double d,
                       int fract)

pln

public static void pln(java.lang.String s)

sleep

public static void sleep(long msec)
Sleeps program for msec milisecond


setInputData

public static void setInputData(java.lang.String s)

getState

public static java.lang.String getState()

setByeMsg

public static void setByeMsg(java.lang.String msg)
Sets end of input message.

Parameters:
msg - - the ending message.

getByeMsg

public static java.lang.String getByeMsg()
Gets end of input message.

Returns:
the message

getLast

public static java.lang.String getLast()
Get last processed element.

Returns:
last element

getError

public static boolean getError()
Indicates whether error condition is raised and reset it to false.

Returns:
true means error.

getEnd

public static boolean getEnd()
The method gives end status.

Returns:
true means end condition.

setEnd

public static void setEnd(boolean e)
The method sets end status.

Parameters:
false - or true.

askStop

public static boolean askStop(java.lang.String query)
The method reads one input line. If line equals bye string end condition is raised. Prompt is eventually printed.

Parameters:
query - message to user to stop input.
Returns:
true if user's reply equals to bye message, false - otherwise.

getDouble

public static double getDouble(java.lang.String s)
The method reads one number from string. If input is not of form of number error condition is raised and NaN is returned. Entered number can be preceded or followed by blanks and tabs.

Returns:
double.

main

public static void main(java.lang.String[] args)