Programming question of the week ;)
Mikael Hansson
EMAIL HIDDEN
Tue Apr 14 22:27:17 CEST 2009
Hey Marc,
M-.-n skrev:
> Also, while I'm at it, it's a typical 'beginner' to try to share as much as
> possible through inheritance. In your case, it's going to be more work to
> inherit all of your class from Item to get a title property than one
> stuffing one in each of them. Unless your high level application *needs* to
> deal with them as the same thing (which doesn't seem to be the way so far),
> don't try to do it "because you can". It's the functionality that drives the
> design before all.
>
> Hope this helps.
> M.
>
It does very much so, but unfortunately I don't have a choice in this
case. I *have* to make an inheritance structure with different kind of
'items' inheriting common properties from the baseclass...academic
regulations :)
The items are to be stored in an array or in a vector.
It's going to be a database for a fictional library. It should read and
save files like this:
Fiction //Type
Morrison, Toni //Author
Song of Solomon //Title
1003 //Unique Id
1007812 //Borrower Id (=0 if available)
NonFiction ...
Gardener, James
Gardening
1004
0
NonFiction
Trainer, Barbara
Aerobics
1005
1003489 ...
CD //Type
Springsteen, Bruce //Artist
The River //Title
83:58 //Playtime
1006 //Unique Id
1001201 //Borrower Id
Journal //Type
C/C++ Users Journal //Title
1/98 //Volume
1007 //Unique Id
0 //Borrower Id
and in the app you should be able to create and remove items, borrow and
return items, search for items by different properties and as I
mentioned before, with two different interfaces, Gui and Console, that
don't invoke any need for changes in the underlying classes when you
switch interface.
My original plan was to first have the basic item+children classes then
a class for the vector with functions for adding, removing, saving,
loading, borrowing and returning. Then a class for interfacing with the
interface classes. Our teacher recommended that the two interface
classes should inherit accessfunctions from an abstract interface class,
that's not written in stone though.
/Micke
More information about the music-bar
mailing list