Results 1 to 7 of 7
  1. #1
    CMuyot is offline Member
    Join Date
    Jul 2012
    Location
    Philippines
    Posts
    3
    Rep Power
    0

    Default Need help for a Newbie :<

    I have an assignment in Java Programming, and there are errors which I can't solve o.o
    Here's the code/s:


    /**
    * Models a simple integer counter.
    */
    public class Counter {
    private int count;
    /**
    * Create a new Counter, with the count initialized
    * to 0.
    */
    public Counter () {
    count = 0;
    }

    /**
    * The number of items counted.
    */
    public int currentCount () {
    return count;
    }

    /**
    * Increment the count by 1.
    */
    public void incrementCount () {
    count = count + 1;
    }

    /**
    * Reset the count to 0.
    */
    public void reset () {
    count = 0;
    }
    }










    /**
    * A simple tester for the class Counter.
    */
    public class CounterTester {

    private Counter counter;

    /**
    * Create a new CounterTester.
    */
    public CounterTester () {
    counter = new Counter();
    }

    /**
    * Run the test.
    */
    public void start () {
    System.out.println("Starting count:");
    System.out.println(counter.currentCount());
    counter.incrementCount();
    counter.incrementCount();
    counter.incrementCount();
    System.out.println("After 3 increments:");
    System.out.println(counter.currentCount());
    counter.reset();
    System.out.println("After reset:");
    System.out.println(counter.currentCount());
    }

    }


    /**
    * Test the class Counter.
    */
    public class Test {

    /**
    * Run a Counter test.
    */
    public static void main (String[] args) {
    CounterTester tester = new CounterTester();
    tester.start();
    }

    }

    It should be in different text files and we're using cmd to compile and run it, but there are errors in it -_-
    Anyone can help me solve this please? :D

    PS: Here's the teacher's instructions:
    1. Copy-paste each class in separate text files. Save the files as Counter.java, CounterTester.java, and Test.java respectively. Compile each class. Run Test.
    2. Draw a graphical representation of an object counterA instantiated of class Counter.
    3. Draw a graphical representation of an object tester1, which is an instance of class CounterTester. Show illustrations of reference values if necessary.
    4. How many constructor/s was/were used when the object tester is created.
    There are 2 constructors used when the object tester is created.
    5. Show a screenshot of your output when you run Test.


    #I'm wondering if I should create the counterA and tester1 so it will run

    Need help for a Newbie :&lt;-java.jpg

  2. #2
    CMuyot is offline Member
    Join Date
    Jul 2012
    Location
    Philippines
    Posts
    3
    Rep Power
    0

    Default Re: Need help for a Newbie :<

    Need some help please >.< I only need an idea on how to connect the programs to each other, thanks

  3. #3
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: Need help for a Newbie :<

    I have no idea what the issue is. I compiled everything and it worked fine. Did you compile the files with conflicting java compiler types? That seems to be the issue here.

    Try recompiling everything with the same version of Javac on the same computer and see what you get.
    My API:
    Java Code:
    cat > a.out || cat > main.class

  4. #4
    CMuyot is offline Member
    Join Date
    Jul 2012
    Location
    Philippines
    Posts
    3
    Rep Power
    0

    Default Re: Need help for a Newbie :<

    When I compile them, there are no errors, but when I run it the error in the screen shot appears.

  5. #5
    mrguy is offline Member
    Join Date
    Jul 2012
    Posts
    27
    Rep Power
    0

    Default Re: Need help for a Newbie :<

    Ive had this before, I think this means the "java" you use is a lower version then your "javac" for example I think your runner is version 6 and your compiler is version 7. update your runner

  6. #6
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: Need help for a Newbie :<

    do:
    Java Code:
     java -version
    and do:
    Java Code:
     javac -version
    and tell us what your output is.
    My API:
    Java Code:
    cat > a.out || cat > main.class

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Need help for a Newbie :<

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Another Newbie
    By Tabula Rasa in forum Introductions
    Replies: 2
    Last Post: 04-25-2011, 12:30 AM
  2. newbie
    By jejerome in forum Introductions
    Replies: 1
    Last Post: 09-22-2010, 03:20 AM
  3. :) newbie...........
    By Somitesh Chakraborty in forum Introductions
    Replies: 1
    Last Post: 08-19-2008, 10:00 AM
  4. newbie newbie newbie
    By krislogy in forum New To Java
    Replies: 9
    Last Post: 08-15-2008, 01:28 AM
  5. Newbie
    By CSnoob87 in forum Introductions
    Replies: 2
    Last Post: 02-18-2008, 09:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •