Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In eclipse Lab Requirements Suppose that we have a set of objects with some common behaviors: they could move up, down, left or right. The
In eclipse
Lab Requirements Suppose that we have a set of objects with some common behaviors: they could move up, down, left or right. The exact behaviors/implementations (such as how to move and how far to move) depends on the objects themselves. One common way to model these common behaviors is to define an interface. In this case, an you will define an interface called Movable, with interface methods moveUp(), moveDown(), moveLeft(), and moveRight all of which return void. (5 points) Write two concrete classes MovablePoint and Movablecircle -that implement the Movable interface. These classes that implement the Movable interface will provide actual implementation to the (abstract) interface methods. Movable Point Class (10 points) For the MovablePoint class, declare the instance variables x, y, xSpeed and yspeed; which represent the x location, y location, speed in the x direction, and speed in the y direction. Make getters and setters for the speed variables only, and one constructor that sets all the (4) instance variables. XSpeed and YSpeed can be positive numbers only, so make sure you program them accordingly (smart setters). Override toString()to an appropriate representation. Implement the movable interface with "logical" implementations that utilize these instance variables. For the MovablePoint, you should be using your ySpeed and xSpeed values for the moveUp/Down and moveLeft/Right methods, respectively. And, you shouldn't be changing your speed in those methods Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started