me again
I want to call a method from another class.
I have
|
I want to use Collection class method remove in RentedCar class. How do I do this?
|
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Felipe RamosPosted Sep 21, 2010, 10:27 AM
Moose PickardPosted Sep 21, 2010, 10:57 AM
The different car classes were relicts. I now see that I could use only one car class. I can use the rent object to represent both rentedIn and rentedOut cars, and the absence of it to represent the cars that are none of the aformentioned.
I updated the diagram: http://www.flickr.com/photos/54126948@N08/5011989040/
Moose PickardPosted Sep 21, 2010, 10:00 AM
I made the Car class abstract because it isn't supposed to be instantiated. I wanted it to be the parent of 2 car class objects so the subclasses could just inherit the variables and methods. For an example If I had 2 or more animals: dog, cat, hippo, and I wanted it to inherit common methods and variables from a superclass, then I would create an animal class. I would also make it abstract because it wouldn't make sense to instantiate an animal.
I actually can't understand why my own structure couldn't work.
Felipe RamosPosted Sep 21, 2010, 8:13 AM
Sam HobbsPosted Sep 20, 2010, 11:23 PM
Moose PickardPosted Sep 20, 2010, 5:09 PM
But the problem is that In my real code the RentedCar is already inheriting from a class and in C# that can be done only once.
I don't really know where to put the inherit code. I can't create an instance from below to higher.Only from high to low: my user object has an instance of CarRental, CarRental has instances of Cars. Or maybe I shouldn't at all call the CarRental method from there, maybe call both methods from form. How could I suit your solution into this?
I made an updated UML: http://www.flickr.com/photos/54126948@N08/5009156825/
Felipe RamosPosted Sep 20, 2010, 3:05 PM