simple graphics package that will allow you to draw and manipulate simple geometric shapes
gazm_8You are developing a simple graphics package that will allow you to draw and manipulate simple geometric shapes such as squares, rectangles, etc. Your initial design is along the following lines:
public class Rectangle { private int h, w; public int getHeight() {…} public int setHeight(int x) {…} ... } |
public class Square extends Rectangle { // ??? } |
This question has a ‘devil’s advocate’ nature to it and is in two parts.
- You intend to model a square as inheriting from a rectangle. How would you complete the code on the above right to realize this intention?
- No matter how you do design the code for the square, you will be able to write code that will break the meaning of what it means to be a square or rectangle. After completing Part a, discuss the flaw in your design and outline some code that will cause it to break (your code should compile fine and will also execute without an error but will violate how a rectangle or square should behave).
- 9 years ago
- 15
Answer(0)
Bids(0)
other Questions(10)
- can anyone do a neumatic rice drying simulation in MATLAB
- assignment
- “I am only one, but still I am one. I cannot do everything, but still I can do something; and because I cannot do everything, I will not refuse to do something that I can do,” -Helen Keller.. Share your thoughts
- Intermediate Accounting II - Homework Assignment
- mgtwk3
- Polymorphism
- project
- Finished
- urgent
- This was due yesterday but the teacher I previously used upped the price after we shaked hands on our agreement need help for one question willing to pay $3 !!