这次ssd9老师布置了一个作业,xiandedanteng,所以我就用python简单的写了一下,大家可以参考一下:
要求如下:
Homework#2
-
SendthesoftcodeofyourmodeltotheemailaddressoftheTA
-
Nolate submission will be accepted
Implementthe classesas shownin thefollowing diagram.You canuse anyprogramming languagewhich supportsobject orientedprogramming suchas Java/C++for implementation.
Youneed to:
-
Providean implementation of all the classes.
-
Inthe mainmethod ofTravelAgency class:
-
createfour instancesof Airplane(such asA380)
-
createcertain numberof Seatfor eachairplane (suchas F4)
-
createtwo instancesof AirlineCompany(such asAmerican Airline)
-
assignairplanes toairline companies
-
createinstances offive customers
-
alloeevery customerbuy twotickets
-
-
Inthe displayTickets()method, foreach airplane:
-
displaythe airlinecompany nameof theticket
-
displaythe airplaneinformation ofthe ticket
-
displaythe seatsinformation inthe airplane
-
displaythe nameof passengerif theseat isnot vacancy
-
Thefull namein ticketisairlineCompany.getID()+airplane.getID()+seat.getID().
Forinstance, UA888F4 meansairline companyid “UA”,airplane id“888” andseat id“F4”.
-
Inthe displayCustomer() method,for eachcustomer display:
-
Thecustomer nameand age
-
Thetickets thatthe customerbought
-
Hint:
Butwhen wedo notwant todisplay students’information fora givencourse
Thedifference iswhen astudent wantsto registera course,he/she hasto putthe courseobject inenrolls[] arrayand put“student.this” tohave[] arrayfor thefirst figure.We justneed toput courseobject inenrolls[] arrayfor thesecond figure.