im creating a file storing system
i have an abstract class called vehicle
then i have 2 more abstract classes called bike and car which extends to vehicle.
then i have another 2 normal classes expensive and cheap which extends to car
what im trying to do is input car details into this system, so i can add, print out all cars etc.....so i need to create arraylists
simple data will be stored such as make, model etc
this is a similar example to what i am doing
thnx for the help
sounds like a hideous design, if you ask me. why are "expensive" and "cheap" classes? they're attributes of something, not objects in their own right. how would you model a cheap bike? why are car and bike abstract? I can't understand why you think "make" and "model" are attributes of a car, but Expensive deserves to be a class of its own. and how did you decide what to make abstract and what to make concrete? why does Vehicle have this ArrayList? I think you need to re-think what you're doing. it makes no sense
lol ok that was just an example remember.
this is the rea thing.....abstract class student
2 abstract class undergrad and postgrad extending to student
2 normal classes hons and foundation extending to undergrad
its the same as the example i gave u b4 but i dunno if this makes things better.
attributes i will need to store for the students will be name, rollnumber, course and module marks.
i need to put all this in the classes such as an arraylist so that i will be able to retrieve, add and print it all out
dont ask me y these classes been made abstract, its just the way it has to be done?
thnx
> lol ok that was just an example remember.
>
> this is the rea thing.....abstract class student
>
> 2 abstract class undergrad and postgrad extending to
> student
>
> 2 normal classes hons and foundation extending to
> undergrad
>
> its the same as the example i gave u b4 but i dunno
> if this makes things better.
> attributes i will need to store for the students will
> be name, rollnumber, course and module marks.
>
> i need to put all this in the classes such as an
> arraylist so that i will be able to retrieve, add and
> print it all out
>
> dont ask me y these classes been made abstract, its
> just the way it has to be done?
says who?
you don't need - or even want - to use an arraylist to store those values. just have them as properties of the class. I wouldn't bother using all that tiresome inheritance, either. is this homework?
heh heh as a rule the forum doesn't do homework, but you at least look like you've done some thinking yourself first.
since it's all about inheritance, consider the following question. you have an opportunity to impress your teacher here
I have a first class honours degree in pure mathematics. I am currently studying as an undergraduate for a degree in petro-chemical engineering. how would you represent me, using the class inheritance as you outlined above?
oops i didnt know but i realy need help
well for me in the student class i will create fields for ur name, roll number, course?
but in the undergrad i dunno what to put in here since i will be inheriting these from student class and for hons, i will be able to inherit from student also i think?
i was thinking putting an arraylist in undergrad so i can store all these data? or would this be better in student?
also was thinking about populating the data...it seems sensible to do this at the start but i dunno where since abstract classes dont have constructors.....unless i have 2 populates one for hons and other for foundation