Results 1 to 12 of 12

Thread: Java

Threaded View

  1. #6
    Xtreme Cruncher
    Join Date
    Dec 2008
    Location
    Texas
    Posts
    5,152

    Post

    Code:
    public class Dot() implements Locatable
    {
    ....int YPos;
    ....int XPos;
    ....int DSize;
    
    ....public int getXPos() //because it implements Locatable it must fulfill these function requests.
    ....{
    ........return XPos;
    ....}
    
    ....public int getYPos()
    ....{
    ........return YPos;
    ....}
    
    ....public Dot()//initialize to default values, 0 could be any default you want
    ....{
    ........int YPos = 0;
    ........int XPos = 0;
    ........int DSize = 0;
    ....}
    
    ....public Dot (int x, int y) //use provided, otherwise default
    ....{
    ........int YPos = x;
    ........int XPos = y;
    ........int DSize = 0;
    ....}
    
    ....public Dot (int x, int y, int size) //everything provided.
    ....{
    ........int YPos = x;
    ........int XPos = y;
    ........int DSize = size;
    ....}
    
    ....public String toString ()
    ....{
    ........return "x = " + XPos + ", y = " + YPos + ", size = " + DSize;
    ....}
    Note: Public must be public, capitalization matters.
    Also, you'll have to remove the ...s, that was just for spacing cuz it wouldn't take tabs.
    Last edited by Otis11; 01-27-2011 at 09:31 PM.


    24 hour prime stable? Please, I'm 24/7/365 WCG stable!

    So you can do Furmark, Can you Grid???

Bookmarks

Bookmarks

Posting Permissions

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