i need to create a class named MyShape(which i did ), and make it a super class. its instance variables should be the x1 x2 y1 y2 values shared by all subclasses.
the class needs to include
1. a no argument constructor
2. constructor that takes the argument necessary to initialize its instance variables
3.sets and gets for all instance variables
4. a toString() method that generates and return a string representation of my shape object
make myLine MyRectangle MyOval subclasses of MyShape delete all instance variables and method posible that are in those classes


i have all the code in the text file but i have trouble with the bold lines

Recommended Answers

All 7 Replies

All it's saying is look for any variables or methods that are the same in all the subclasses and move those into the superclass so they only appear once. Each of the subclasses will inherit them all from the superclass, so there's no need to duplicate them in every subclass.

which variables or methods do i need to erase

The redundant ones, just like James said above.

is there a way that you can show me how

Please, you are embarrassing yourself.
Stop panicking and start thinking.
Try following the instructions we've given you.

well, i am only trying to get second opinion, but anyway

I deleted from each class it's instant variable and their sets and gets methods, and i left the non argument constructor and the constructor that take the x's and y's and the color
and extended each class to the MyShape class

hope i wont get any poins drop from it

OK. Don't forget to add those variables and methods to the superclass. You were right to keep the constructors in the subclasses, because constructors are not inherited.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.