View Single Post
Old 02-05-2004, 18:15   #2 (permalink)
muppet77
Muppet Punter
 
muppet77's Avatar
 
Join Date: 26 Oct 2004
Posts: 1,990
Default Lesson 3 - Language, a bit more about objects

datapunter - what's the edit you made?


I'm using html in these posts to get all the indenting right, but thats a monks work, so easy to make a little mistake, nobody noticed then thought i got away with that one

This was wrong,

public class Scoreboard {
    public int home = 0;
    public int away = 0;

    public Scoreboard(int home, int away)
    {
      this.home = home;
      this.away = away;

    .................................................. .... <-- closing bracket is missing

    public int goals()
    {
      return home + away;
    } .................................................. .... <-- closing bracket is in wrong place
    }
}


This is right,
public class Scoreboard {
    public int home = 0;
    public int away = 0;

    public Scoreboard(int home, int away)
    {
      this.home = home;
      this.away = away;
    }

    public int goals()
    {
      return home + away;
    }
}
muppet77 is offline