Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a class point, which contains two instance variables x and y, a non-defau

ID: 3634117 • Letter: D

Question

Design a class point, which contains two instance variables x and y, a non-default constructor, a a void changeCoordBy (int x, int y) method, and a toString method. Then, consider the diagram below representing a hierarchy of classes. Implement the classes and test them with the following main :

public static void main(String[] args){
Shape mySquare = new Square(0,0,"blue",2);
Shape myCircle = new Circle(4,4,"black",1);
for (int i = 1; i<5 ; i++){
System.out.println("Printing Shapes");
System.out.println("---------------");
mySquare.display();
myCircle.display();
if (mySquare.area()>myCircle.area())
System.out.println("**********Square larger");
else System.out.println("**********Circle larger");
System.out.println();

mySquare.moveX(3);
myCircle.moveY(-3);

mySquare.zoom(1.4);
myCircle.zoom(1.5);
}
System.out.println("Changing Colours");
System.out.println("----------------");
mySquare.changeColour("black");
myCircle.changeColour("white");
mySquare.display();
myCircle.display();
}


SHAPE:
Instance variables:
• point
• colour
methods:
• area() depending on which shape object
• zoom(dMethoouble ratio) depending on which shape
• display()
• moveX(int x)
• moveY(int x)
• changeColour(String newColour)

SQUARE:
Instance variables:
• side
Methods:
• area()
• zoom(double ratio)

CIRCLE:
Instance variables:
• radius
Methods:
• area()
• zoom(double ratio)




Explanation / Answer

dear plz check these sites... http://docs.oracle.com/javase/tutorial/java/javaOO/objectcreation.html http://www.xyzws.com/scjp/SGS11/1/12 http://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html http://leepoint.net/notes-java/oop/constructors/constructor.html

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote