Jump to content

Help college program f'ed and dead line aproaching


Duz

Recommended Posts

Seriously, this program is so simple you shouldn't need help. Java is a high level language and can do each function your program needs to do in a single line of code.

The program you are required to write would even be quite simple to do in assembler.

Link to comment
Share on other sites

Eww, Moodle.

Oh - just checking you saw this?

Academic Honesty

You may help each other to complete labs, as the purpose of the labs is to increase your

understanding. This, however, this does not mean that someone else can do your lab

work for you, or that you can do someone else’s work for them. Any work that you

submit for continuous assessment or assignments must contain a significant contribution

by you. Any help you receive from someone must be acknowledged in the work

submitted. Failure to acknowledge the source of a significant idea or approach is

considered plagiarism and not allowed. Academic dishonesty will be dealt with severely.

At a minimum, you will receive a mark of zero for the assignment.

Link to comment
Share on other sites

Although I didn't actually compile your program, it looks like you deleted or moved the Keyboard.java file. Since Java is only compiled to bytecode instead of binary, you should be able to decompile the Keyboard.class file to retrieve the original source without comments.

I decompiled the Keyboard.class file in the classes folder for you. Put the following code in a file called Keyboard.java in the src folder and then recompile. It should work this time.

Hope this helps. Good Luck.

import java.io.*;
import java.util.StringTokenizer;

public class Keyboard
{

    public Keyboard()
    {
    }

    public static int getErrorCount()
    {
        return errorCount;
    }

    public static void resetErrorCount(int i)
    {
        errorCount = 0;
    }

    public static boolean getPrintErrors()
    {
        return printErrors;
    }

    public static void setPrintErrors(boolean flag)
    {
        printErrors = flag;
    }

    private static void error(String s)
    {
        errorCount++;
        if(printErrors)
            System.out.println(s);
    }

    private static String getNextToken()
    {
        return getNextToken(true);
    }

    private static String getNextToken(boolean flag)
    {
        String s;
        if(current_token == null)
        {
            s = getNextInputToken(flag);
        } else
        {
            s = current_token;
            current_token = null;
        }
        return s;
    }

    private static String getNextInputToken(boolean flag)
    {
        String s = null;
        try
        {
            if(reader == null)
                reader = new StringTokenizer(in.readLine(), " \t\n\r\f", true);
            for(; s == null || " \t\n\r\f".indexOf(s) >= 0 
&& flag; s = reader.nextToken())
                for(; !reader.hasMoreTokens(); 
reader = new StringTokenizer(in.readLine(), " \t\n\r\f", true));

        }
        catch(Exception exception)
        {
            s = null;
        }
        return s;
    }

    public static boolean endOfLine()
    {
        return !reader.hasMoreTokens();
    }

    public static String readString()
    {
        String s;
        try
        {
            for(s = getNextToken(false); !endOfLine(); 
s = (new StringBuilder()).append(s).append(getNextToken(false)).toString());
        }
        catch(Exception exception)
        {
            error("Error reading String data, null value returned.");
            s = null;
        }
        return s;
    }

    public static String readWord()
    {
        String s;
        try
        {
            s = getNextToken();
        }
        catch(Exception exception)
        {
            error("Error reading String data, null value returned.");
            s = null;
        }
        return s;
    }

    public static boolean readBoolean()
    {
        String s = getNextToken();
        boolean flag;
        try
        {
            if(s.toLowerCase().equals("true"))
                flag = true;
            else
            if(s.toLowerCase().equals("false"))
            {
                flag = false;
            } else
            {
                error("Error reading boolean data, false value returned.");
                flag = false;
            }
        }
        catch(Exception exception)
        {
            error("Error reading boolean data, false value returned.");
            flag = false;
        }
        return flag;
    }

    public static char readChar()
    {
        String s = getNextToken(false);
        char c;
        try
        {
            if(s.length() > 1)
                current_token = s.substring(1, s.length());
            else
                current_token = null;
            c = s.charAt(0);
        }
        catch(Exception exception)
        {
            error("Error reading char data, MIN_VALUE value returned.");
            c = '\0';
        }
        return c;
    }

    public static int readInt()
    {
        String s = getNextToken();
        int i;
        try
        {
            i = Integer.parseInt(s);
        }
        catch(Exception exception)
        {
            error("Error reading int data, MIN_VALUE value returned.");
            i = 0x80000000;
        }
        return i;
    }

    public static long readLong()
    {
        String s = getNextToken();
        long l;
        try
        {
            l = Long.parseLong(s);
        }
        catch(Exception exception)
        {
            error("Error reading long data, MIN_VALUE value returned.");
            l = 0x8000000000000000L;
        }
        return l;
    }

    public static float readFloat()
    {
        String s = getNextToken();
        float f;
        try
        {
            f = (new Float(s)).floatValue();
        }
        catch(Exception exception)
        {
            error("Error reading float data, NaN value returned.");
            f = (0.0F / 0.0F);
        }
        return f;
    }

    public static double readDouble()
    {
        String s = getNextToken();
        double d;
        try
        {
            d = (new Double(s)).doubleValue();
        }
        catch(Exception exception)
        {
            error("Error reading double data, NaN value returned.");
            d = (0.0D / 0.0D);
        }
        return d;
    }

    private static boolean printErrors = true;
    private static int errorCount = 0;
    private static String current_token = null;
    private static StringTokenizer reader;
    private static BufferedReader in;

    static 
    {
        in = new BufferedReader(new InputStreamReader(System.in));
    }
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...