Difference between revisions of "Xinu Helper Class"

From Embedded Xinu
Jump to navigation Jump to search
(not done yet)
 
(finished page)
 
Line 2: Line 2:
  
  
<code>import java.util.Scanner;
+
<pre>import java.util.Scanner;
 
public class Xinu
 
public class Xinu
 
{
 
{
 
     public static int readint()
 
     public static int readint()
 
     {
 
     {
    Scanner scanner = new Scanner(System.in);
+
        Scanner scanner = new Scanner(System.in);
    return scanner.nextInt();
+
        return scanner.nextInt();
 
     }
 
     }
 
     public static void printint(int x)
 
     public static void printint(int x)
 
     {
 
     {
    System.out.println(x);
+
        System.out.println(x);
 
     }
 
     }
 
     public static void print(String s)
 
     public static void print(String s)
 
     {
 
     {
    System.out.print(s);
+
        System.out.print(s);
 
     }
 
     }
 
     public static void println()
 
     public static void println()
 
     {
 
     {
    System.out.println();
+
        System.out.println();
 
     }
 
     }
 
     public static void yield()
 
     public static void yield()
Line 50: Line 50:
 
         t.start();
 
         t.start();
 
     }
 
     }
}</code>
+
}</pre>

Latest revision as of 23:06, 31 July 2010

Here is the full Java source code for the Xinu.java helper class.


import java.util.Scanner;
public class Xinu
{
    public static int readint()
    {
        Scanner scanner = new Scanner(System.in);
        return scanner.nextInt();
    }
    public static void printint(int x)
    {
        System.out.println(x);
    }
    public static void print(String s)
    {
        System.out.print(s);
    }
    public static void println()
    {
        System.out.println();
    }
    public static void yield()
    {
        Thread thisThread = Thread.currentThread();
        try
        {
            thisThread.yield();
        }
        catch (Exception e)
        {
            System.out.println(e);
        }
    }
    public static void sleep(int time)
    {
        Thread thisThread = Thread.currentThread();
        try
        {
            thisThread.sleep(time);
        }
        catch (Exception e)
        {
            System.out.println(e);
        }
    }
    public static void threadCreate(Thread t)
    {
        t.start();
    }
}