Package

Source Code of App

import tools.ScanReader;
import java.io.*;

public class App {
  private static ScanReader sr;

  public static void main (String[] args) throws Exception {
    System.out.println("[Test na łańcuchu]");
    stringTest();
    System.out.println("[Test na pliku]");
    fileTest();
    //System.out.println("\n\n[Test na wejściu standardowym]");
    //systemInTest();
  }

  public static void stringTest () {
    String s="          123.123\n123.123d  \n123";
    sr = new ScanReader(new StringReader(s));
    scanDouble();
    scanDouble();
    scanDouble();
    scanDouble();
  }

  public static void fileTest () throws Exception {
    FileReader f = new FileReader("test");
    sr = new ScanReader(new BufferedReader(f));
    scanByte();
    scanByte();
    scanId();
    scanId();
    scanDouble();
    scanDouble();
    scanDouble();
    scanDouble();
    scanInt();
    scanInt();
    scanString();
    scanEOLn();
    scanString();
    scanString();
    scanString();
  }

  public static void systemInTest () {
    Reader we = new BufferedReader(new InputStreamReader(System.in));
    sr = new ScanReader(we);
    scanDouble();
    scanDouble();
    scanDouble();
  }

  public static void scanInt() {
    try {
      System.out.println(sr.scanInt());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  public static void scanDouble() {
    try {
      System.out.println(sr.scanDouble());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  public static void scanByte() {
    try {
      System.out.println(sr.scanByte());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  public static void scanId() {
    try {
      System.out.println(sr.scanId());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  public static void scanIntHex() {
    try {
      System.out.println(sr.scanIntHex());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  public static void scanIntBin() {
    try {
      System.out.println(sr.scanIntBin());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  public static void scanEOLn() {
    try {
      System.out.println(sr.scanEOLn());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  public static void scanString() {
    try {
      System.out.println(sr.scanString());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  public static void skipWS() {
    try {
      System.out.println(sr.skipWS());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  public static void isEOF() {
    try {
      System.out.println(sr.isEOF());
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }
}
TOP

Related Classes of App

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.