Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Implementations!

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Implementations!

    Assume the existence of an interface, GUIComponent with the following methods: - open and close: no parameters, returns boolean - move and resize: accepts two integer parameters and returns void
    Define a class, Window, that implements the GUIComponent interface, and has the following members: - width, height, xPos, and yPos integer instance variables, with xPos and yPos initialized to 0 - a constructor that accepts two integer variables (width followed by height) which are used ti initialize the width and height instance variables - An implementation of open: that sends "Window opened" to System.out, and returns true - An implementation of close that sends "Window closed" to System.out, and returns true - An implementation of resize that modifies the width and height variables to reflect the specified size - An implementation of move that modifies xPos and yPos to reflect the new position.

    this is what i have:


    public class Window implements GUIComponent{
    private int width;
    private int height;
    private int xPos = 0;
    private int yPos = 0;

    public Window(int width, int height){
    width=num1;
    height=num2;
    {
    public boolean open(){
    System.out.println("Window opened")
    return true;
    }
    public boolean close(){
    System.out.println("Window closed")
    return true;
    }
    public void resize(){
    int width=x
    int height=y
    return void;
    }
    public void move(){
    int xPos=3
    int yPos =4
    return void;
    }
    }
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Implementations!

    Do you have a question?

    Please Edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Implementations!

    the question is at the top, my answer is at the bottom. after the bold.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Implementations!

    Sorry, I don't see your question. All I see is what looks like your assignment. I'm looking for something that ends with a ?
    If you have any specific questions about your assignment, ask them.

    Please Edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Implementations!

    Does your code compile? You'll have to write the interface code as well to find out.

    If it doesn't compile and you can't understand why, post the full compiler message and say what lines of your code it is referring to.