Welcome! Log In Create A New Profile

Advanced

Assignment 3 Question 1

Posted by Henry 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar Assignment 3 Question 1
May 05, 2009 10:26PM
This question is puzzling me. It refers to exercise 5.1, which does not really give a good description of what needs to be done. It refers to some common attributes for the three shape classes, and then don't bother to give the attributes, or what? Am I reading like my arse again?
Re: Assignment 3 Question 1
May 05, 2009 11:41PM
The only thing I have common between all the shapes is the fact that the attributes are all integers, that and the methods that are specified in the shape interface.
All my shapes only have the attributes listed in the table.
avatar Re: Assignment 3 Question 1
May 06, 2009 09:25AM
Yes, but the attributes are different for each shape. A circle has an center and a radius, a line an origin and an end, a rectangle an origin with horisontal and vertical size.
avatar Re: Assignment 3 Question 1
May 06, 2009 10:00AM
Yeah, that's what I mean smiling smiley
avatar Re: Assignment 3 Question 1
May 07, 2009 07:25AM
Erm....

All the shapes have an X and Y position and then some attribute.

So I interpret it to mean that at the top of the hierarchy the shape class contain the X and Y coords,
and then each sub class contains their specific attributes like radius or width etc.

on pg 204 Ex 5.1.b.i) It shows how each class is called (ie yes henry, you reading like your arse again)

========================
assert( MyBrain != null)
avatar Re: Assignment 3 Question 1
May 07, 2009 07:56AM
All of the classes do have a toString() function.

And that is about the only commonality I could think of that you could express in an interface.

Cobus Neethling
avatar Re: Assignment 3 Question 1
May 07, 2009 01:25PM
Yes, but toString() is already a method in the Object class, so there is absolutely no point in adding it to my Shape interface definition.

Toxic...I can't really see how that has got anything to do with the interface definition. The reading of the shape data from file should be handled by the serialisation methods that needs to be defined in each of the shape classes, and there is already a Serializable interface definition for that.

The attributes may all be integers, but the function for each attribute is different for each shape. Adding say a getOrigin() method to the Shape interface is bad design, since you would have to cast up to access the other unique attributes like radius, width, height and endpoint.

This exercise is really a very bad one to explain the use of interfaces to provide loosely coupled code. Really the only thing a noob can take out of this is adding serialisation and all that other canonical crap to the classes.
Sorry, only registered users may post in this forum.

Click here to login