I've gotten further with my program and now need to interconnect the pieces.
My program has many CarRental services, which all can rent cars in and out between them.
Diagram:
I was thinking about the problem and I came up with some ideas. I don't know if they are ok.
One class can have only one event? Is the event way the right way to do this?
There is a CarRentalEventArgs class, which creates the car object, and also has, int rentLenght, owner ID.
This CarRentalEventArgs object is then passed into different methods of the CarRental class, if the ownerID = MyID then the Car is returned by the renter, if the ID's don't match, then it is rented by the same CarRental, that picks up the event.
I am however stuck now. I don't know what to do.
Are there any good tutorials? Or is there some logic to follow?
Moose PickardPosted Sep 26, 2010, 10:09 AM
"You don't need events for that."
What do I need then? To make this exact arhitecture work?
"You do need to learn how software is designed."
I problably do. Any good tutorials, info you'd suggest?
I tried to design it from OOP view. I think in that I have somewhat succeeded.
I didn't however choose the standard way these things are done, as you suggested in an earlier post in another topic.
Because I thought it wasn't what I needed.
Sam HobbsPosted Sep 26, 2010, 5:57 AM
Moose PickardPosted Sep 26, 2010, 5:41 AM
At first when the program runs the carRental objects are created, there can be infinitely many.
For example CarRental m is logged in, and watches a list of cars in forms app. Then he picks the car he wants to rent. The owner of these cars is CarRental o.
So he chooses to rent this car. That's where I figured I could use events. The CarRental m sends out event that it wants to rent a car, to the CarRental o. The CarRental o EventHandler catches it and sends out the Car object, with information about the owner and renttime
I have no other idea how could I do this any other way. The CarRental objects don't have instances of themselves. And they don't inherit from eachother.
Thanks for the reply.
Sam HobbsPosted Sep 25, 2010, 6:49 PM