Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

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 4 of 4

Threaded View

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

    Default Java Object Oriented Problem

    Hi, I am a fresh graduate from Diploma in IT. Recently I just went to an interview. The interviewer gave me a question. The question is, he want me to code him a program, base on a snake game(quite popular in nokia oldies handphone). Not a full program actually but just a part only. You have 4 buttons for go left, go right, go up, and go down. It also have a calculationOfAxis per second for the movement rate of the snake and also a callSnake function for the GUI. Below is a rough example of the function.

    moveUp(){...}
    moveDown(){...}
    moveRight(){...}
    moveLeft(){...}

    calculationOfAxis(x-axis, y-axis){
    callsnake()
    }

    Then he ask me that if I want to change the GUI of the snake, what should I do? Then I replied him just change the codes of the snake to car. Then he told me that wouldn't it be better if you do it in another way than keep changing your codes? Then i came out a solution which is the code below.

    public class Parents(){
    moveUp(){....};
    moveDown(){...};
    moveRight(){...};
    moveLeft(){...};
    calculationOfAxis(x-axis, y-axis){...};
    }

    public class Child extends Parents(){
    super(moveUp(),moveDown(),moveRight(),moveLeft(),c alculationOfAxis(x,y);

    callcar();
    }

    After that I said you can call whatever you want in the child class [eg: callShip(), callMotor()]

    Then he said my answer is acceptable but not the efficient way. So, he gave me a situation which he said that his company project roughly consists of millions of code. He want a method to add a new features in the project without the need of editing the existing code and can guarantee it will work with the old codes. He also said that he want to test the new codes ONLY. You can neglect the old codes for the sake of saving time.

    Well, that is where I am stuck now. Honestly I don't really quite get what he want. So, hopefully someone can show me the solution of this question.
    Last edited by -j-t-; June 12th, 2012 at 08:06 AM. Reason: bad english


Similar Threads

  1. help for Object Oriented Programming RMI
    By clapton in forum Object Oriented Programming
    Replies: 2
    Last Post: March 22nd, 2012, 05:38 AM
  2. Object oriented programming
    By merr78 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 9th, 2012, 01:32 AM
  3. Object oriented programming
    By jonnitwo in forum Object Oriented Programming
    Replies: 8
    Last Post: September 2nd, 2011, 12:18 PM
  4. Object-oriented mess
    By mjpam in forum Object Oriented Programming
    Replies: 3
    Last Post: May 7th, 2011, 11:27 AM
  5. Object-oriented applet
    By mjpam in forum Object Oriented Programming
    Replies: 26
    Last Post: September 15th, 2010, 06:43 AM