me again
I want to call a method from another class.
I have
Code Code Code Code Code Code Code Code Code |
I want to use Collection class method remove in RentedCar class. How do I do this?
Code Code Code Code Code Code Code Code Code |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Felipe RamosRank #1,409 · 1.2K reputationPosted Sep 21, 2010, 6:27 AM EDT
Felipe RamosRank #1,409 · 1.2K reputationPosted Sep 20, 2010, 11:05 AM EDT
Moose Pickard64 reputationPosted Sep 20, 2010, 1:09 PM EDT
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/
Sam HobbsRank #107 · 20.5K reputationPosted Sep 20, 2010, 7:23 PM EDT
Felipe RamosRank #1,409 · 1.2K reputationPosted Sep 21, 2010, 4:13 AM EDT
Moose Pickard64 reputationPosted Sep 21, 2010, 6:00 AM EDT
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.
Moose Pickard64 reputationPosted Sep 21, 2010, 6:57 AM EDT
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/