Best usage and examples of inheritance

Associate
Joined
18 Feb 2010
Posts
940
Hi,

I'm doing a little bit of lab work and have to set a coursework. I've been thinking of ideas for a programming task regarding inheritance. I was considering chess pieces but don't really want to do a game since some people will have the disadvantage of not knowing the rules. There is also shapes inheriting from a shape class but it's a bit too simple. I'm looking for something fun, with multiple sub classes and which isn't too easy (it's a final piece).

Any ideas? I'm just looking for good real world ideas, a little inspiration.
 
Last edited:
Associate
OP
Joined
18 Feb 2010
Posts
940
The classic one is some sort of motor vehicle I thought.

Yep, I read that in a few books too and was thinking about that one.
It needs to be a bit difficult though, perhaps:

Vehicle class extended by car, truck, motorbike, sportscar, pushbike

A race object which can take a list of vehicles and a track in the constructor and has a start() method perhaps.

A track object which is probably read from a file. Different vehicles can be better or worse at certain parts of the track, ie motorbike is better at turning, a sportscar is faster on straights.

hmmm. Still thinking.
 
Associate
OP
Joined
18 Feb 2010
Posts
940
Can you define "a bit difficult"? What level of student are you teaching - night class, A-Level, final year University Comp Science? (I hope not the last!)

If all you're trying to teach is the concept of inheritance, this isn't particularly difficult and a simple task or two would be best. If you're setting some kind of final test for a whole programming course, then your race/track modelling idea starts to make sense.

Final as in University last coursework 1st year, not final as in final year. Some interesting ideas here.
 
Back
Top Bottom