Implement classes rectangle and Circle inherit from the abstract class Shape. pu
ID: 3655190 • Letter: I
Question
Implement classes rectangle and Circle inherit from the abstract class Shape. public abstract class Shape { // Usage: p = s.getCenter() // before: nothing // after: p is the middle of s public abstract Point2D getCenter(); // usage: r = s.getBoundingBox() // before: nothing // after: r is the smallest rectangle that fits around the s public abstract Rectangle getBoundingBox(); // useage: c = s.intersects(o) // before: nothing // after: c is true of s and o overlaps public abstract boolean intersects(Shape o); // useage: s.scale(f) // before: f > 0 // after: s is f-times bigger and the middle is the same public abstract void scale(double f); } Add a rectangle clusters methods getWidth, getHeight, setWidth and seth eight and describe them. Add to Circle as the cluster method getRadius. If the class Square would inherit from rectangle, how would pre-condition data look for that class? What methods would break pre-condition data or reasoned programming this class? How would your answer change if clusters were unchanged If the class Square would inherit from rectangle, how would pre-condition data look for that class? What methods would break pre-condition data or reasoned programming this class? How would your answer change if clusters were unchanged.Explanation / Answer
abstract class Shape{ final int b = 20; public void display(){ System.out.println("This is display method"); } abstract public void calculateArea(); } class Rectangle extends Shape{ public static void main(String args[]){ Rectangle obj = new Rectangle(); obj.display(); //obj.b=200; } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.