Background
I'm planning a project towards the end of my intro course to C#. So I'm new to this but can handle the basics. I'm just starting to get the hang of classes and objects now too, at least in theory. Since this is a project towards the end of a course, I don't ask for coding help per se but rather some guidance to get my head around the structure:
Idea
- The concept is a playful boarding simulation of an airplane having say 200 seats divided into 2 sections, business (e.g. 48 seats) and economy (remaining seats). A
Run()method will be added that contains aswitch-casemenu with different options. The 'user' of the program might be the boarding gate agent.
I'm making the airplane into a class,
class Airplane()but I don't get how to create the cabin sections. Should I declare array with 2 positions which I populate with two cabin section instances? Or an array with 200 positions for the total 200 seats? I think I see a problem here as the sections contain different amount of seats...
- The airplane will be boarded with passengers
class Passenger(), each having gender, age and weight, this should be easy. I want it to be a "semi-automatic" method insideclass Airplane()to populate only half of the available 200 seats with passengers, but randomly spread across the whole cabin (some in business, some in economy) and leave the other seats empty. It's like a quick random priority boarding.
This is where my main head ache is. The airplane has a finite number of seats, 48 in one instance and 152 in the other, total 200. How can I fill 100 instances of
Passenger()randomly across all 200 seats and leave "gaps" that will be added later?
- Another method should then allow the user to board a single passenger one by one (again random age and gender) so same method approach as before but this time specifically choose whether to board him/her to business or economy. This is because I want to return a message if a section is full, and eventually if the whole airplane is full. The message part should be simple. Obviously, each added instance of the passenger in this case can only be stored where another passenger is not already seated (fill up the remaining 100 positions) = not simple.
I need to figure out later how this method should work (fill to either business or econ), but ignoring that detail for now, how can I keep track of the empty seats (the gaps in the array) so the 'manual board' method knows where to populate the remaining instances of passenger?
There are other things I'm adding to this too but it feels more straight forward. Things like standard weight attribute depending on age, response method depending on age and gender if I bump() into someone, and methods for calculating totals and averages at any time for age, gender, weights in the airplane as a whole or by section...
Appreciate your feedback! Only please explain how to structure it up to get it to work, i.e. what should be class, object, method, array or list etc and how to get around the problems described, and I will try to work out the actual code. Be gentle, I'm still a beginner. Thanks!
Aucun commentaire:
Enregistrer un commentaire