473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Update an element of a vector

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4.  
  5. #include<string.h>
  6. #include<iomanip>
  7. #include<iostream>
  8. #include<vector>
  9. #include<list>
  10.  
  11. using namespace std;
  12.  
  13.                             //  Movie Class
  14. class Movie{
  15. private:
  16. int movieNum;
  17. char * Title;
  18. public:
  19. Movie();
  20. Movie(char * inTitle);
  21. void setMovieNum();
  22. void setTitle(char *inTitle);
  23.  
  24. int getMovieNo();
  25. char* getMovieTitle();
  26. };
  27.  
  28. // getters and setters
  29.  
  30. Movie::Movie(){
  31. setMovieNum();
  32. char setTitle1[]="Untitled";
  33. setTitle(setTitle1);
  34. }
  35.  
  36. Movie::Movie(char *inTitle){
  37. setMovieNum();
  38. setTitle(inTitle);
  39. }
  40.  
  41.  
  42. void Movie::setMovieNum(){
  43. static int MovieCount =0;
  44. MovieCount++;
  45. movieNum = MovieCount;
  46. }
  47.  
  48. void Movie::setTitle(char *inTitle){
  49. Title = inTitle;
  50. }
  51.  
  52. int Movie::getMovieNo(){
  53. return    movieNum;
  54. }
  55.  
  56. char* Movie::getMovieTitle(){
  57. return Title ;
  58. }
  59.  
  60.                                 // Passenger Class
  61. class Passenger{
  62. private:
  63. int bookingRefNo;
  64. char name[50];
  65. int numAdult;
  66. int numChildren;
  67. int numFlights;
  68. double totalPrice;
  69.  
  70. public:
  71. Passenger();
  72.  
  73. //Getters and Setters
  74. void setBookingRef();
  75. void setName(char inName[50]);
  76. void setNumAdult(int noAdult);
  77. void setNumChildren(int noChild);
  78. void setNumFlight(int noFlight);
  79. void setTotalPrice(double inTotalPrice);
  80.  
  81.  
  82. int getBookingRef();
  83. char * getName();
  84. int getNumAdult();
  85. int getNumChildren();
  86. int getNumFlight();
  87. double getTotalPrice();
  88. };
  89. //setter methods
  90. Passenger::Passenger(){
  91. setBookingRef();
  92. }
  93.  
  94. void Passenger::setBookingRef(){
  95. static int count=500;
  96. count++;
  97.  
  98. bookingRefNo=count;
  99. }
  100. void Passenger::setName(char inName[50]){
  101. strcpy(name,inName);
  102. }
  103. void Passenger::setNumAdult(int noAdult){
  104. numAdult = noAdult;
  105. }
  106. void Passenger::setNumChildren(int noChild){
  107. numChildren = noChild;
  108. }
  109. void Passenger::setNumFlight(int noFlight){
  110. numFlights = noFlight;
  111. }
  112. void Passenger::setTotalPrice(double inTotalPrice){
  113. totalPrice = inTotalPrice;
  114. }
  115. //getter methods
  116. int Passenger::getBookingRef(){
  117. return bookingRefNo;
  118. }
  119. char* Passenger::getName(){
  120. return name;
  121. }
  122. int Passenger::getNumAdult(){
  123. return numAdult;
  124. }
  125. int Passenger::getNumChildren(){
  126. return numChildren;
  127. }
  128. int Passenger::getNumFlight(){
  129. return numFlights;
  130. }
  131. double Passenger::getTotalPrice(){
  132. return totalPrice;
  133. }
  134.  
  135.                                         // Fligh Class
  136.  
  137. class Flight{
  138.  
  139. private:
  140. int flightNo;
  141. char orgin[50];
  142. char destination[50];
  143. char date[50];
  144. char deparR[50];
  145. double price;
  146. int childPerc;
  147. vector<Movie> movieList;
  148.  
  149. public:
  150.  
  151. Flight();
  152. Flight(char InOrgin[50], char InDesi[50], char InDate[50], char InDeparr[50], double inPrice, int ChildPerc);
  153. void SetflightNo();
  154. void SetOrgin(char InOrgin[50]);
  155. void SetDesti(char InDesti[50]);
  156. void SetDate(char InDate[50]);
  157. void SetDeparr(char InDeparr[50]);
  158. void SetPrice(double InPrice);
  159. void SetChildPerc(int InChildPerc);
  160.  
  161. int  GetflightNo();
  162. char* GetOrgin();
  163. char* GetDesti();
  164. char* GetDate();
  165. char* GetDeparr();
  166. double GetPrice();
  167. int GetChildPerc();
  168. void addMovie(Movie objMov);
  169.  
  170.  
  171. };
  172. Flight::Flight(){
  173. SetflightNo();
  174. char SetOrgin1[]="null";
  175. SetOrgin(SetOrgin1);
  176. char SetDesti1[]="null";
  177. SetDesti(SetDesti1);
  178. char SetDeparr1[]="null";
  179. SetDeparr(SetDeparr1);
  180. SetPrice(0.0);
  181. SetChildPerc(0);
  182. }
  183. Flight::Flight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int InChildPerc){
  184. SetflightNo();
  185. SetOrgin(InOrgin);
  186. SetDesti(InDesi);
  187. SetDeparr(InDeparr);
  188. SetPrice(inPrice);
  189. SetChildPerc(InChildPerc);
  190. }
  191. //setter methods
  192. void Flight::SetflightNo(){
  193. static int flightCount=100;
  194. flightCount++;
  195. flightNo = flightCount;
  196.  
  197. }
  198.  
  199. void Flight:: SetOrgin(char InOrgin[50]){
  200. strcpy(orgin,InOrgin);
  201. }
  202.  
  203. void Flight::SetDesti(char InDesti[50]){
  204. strcpy(destination,InDesti);
  205. }
  206. void Flight::SetDate(char InDate[50]){
  207. strcpy(date,InDate);
  208. }
  209. void Flight::SetDeparr(char InDeparr[50]){
  210. strcpy(deparR,InDeparr);
  211. }
  212. void Flight::SetPrice(double InPrice){
  213. price = InPrice;
  214. }
  215. void Flight::SetChildPerc(int InChildPerc){
  216. childPerc = InChildPerc;
  217. }
  218. //getter methods
  219. int Flight::GetflightNo(){
  220. return flightNo;
  221. }
  222.  
  223.  
  224. char* Flight:: GetOrgin(){
  225. return orgin;
  226. }
  227.  
  228. char* Flight::GetDesti(){
  229. return destination;
  230. }
  231. char* Flight::GetDate(){
  232. return date;
  233. }
  234. char* Flight::GetDeparr(){
  235. return deparR;
  236. }
  237.  
  238. double Flight::GetPrice(){
  239. return price;
  240. }
  241.  
  242. int Flight::GetChildPerc(){
  243. return childPerc;
  244. }
  245. // add movie   for a flight
  246. void Flight::addMovie(Movie objMov){
  247. movieList.push_back(objMov);
  248.                                                 //Business Flight Class
  249. class BusinessFlight : public Flight{
  250. private:
  251. double rate;
  252.  
  253. public:
  254.  
  255. BusinessFlight();
  256. BusinessFlight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int ChildPerc, double inRate);
  257. void SetRate(double InRate);
  258. double GetRate();
  259. Passenger Book(Passenger obj);
  260. };
  261. // getters and setters
  262. BusinessFlight::BusinessFlight():Flight(){
  263. SetRate(0.0);
  264. }
  265.  
  266. BusinessFlight::BusinessFlight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int ChildPerc, double 
  267.  
  268. inRate):Flight(InOrgin,InDesi,InDate,InDeparr,inPrice,ChildPerc)
  269. {
  270. SetRate(inRate);
  271. }
  272.  
  273. // add Passenger for a business class
  274. Passenger BusinessFlight::Book(Passenger obj){
  275. double adultPrice;
  276. double childPrice;
  277. double totalPrice;
  278. adultPrice = obj.getNumAdult() * GetPrice() * GetRate();
  279. childPrice = obj.getNumChildren() * (double) GetChildPerc()/100 * GetRate();
  280. totalPrice = adultPrice + childPrice;
  281. obj.setTotalPrice(totalPrice);
  282. obj.setNumFlight(GetflightNo());
  283. return obj;
  284. }
  285. //setter methods
  286. void BusinessFlight::SetRate(double InRate){
  287. rate = InRate;
  288. }
  289. //getter methods
  290. double BusinessFlight::GetRate(){
  291. return rate;
  292. }
  293.  
  294.                                                  //EconomyFlight Class
  295. class EconomyFlight : public Flight{
  296. private:
  297. public:
  298. EconomyFlight();
  299.     EconomyFlight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int ChildPerc);
  300. Passenger Book(Passenger obj);
  301. };
  302.  
  303. EconomyFlight::EconomyFlight(){
  304.  
  305. }
  306. // add passenger for an Economy class
  307. Passenger EconomyFlight::Book(Passenger obj){
  308. double adultPrice;
  309. double childPrice;
  310. double totalPrice;
  311. adultPrice = obj.getNumAdult() * GetPrice();
  312. childPrice = obj.getNumChildren() * (double) GetChildPerc()/100;
  313. totalPrice = adultPrice + childPrice;
  314. obj.setTotalPrice(totalPrice);
  315. obj.setNumFlight((int)GetflightNo());
  316. return obj;
  317. }
  318. EconomyFlight::EconomyFlight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int ChildPerc):Flight
  319.  
  320. (InOrgin,InDesi,InDate,InDeparr,inPrice,ChildPerc){
  321.  
  322. }
  323.  
  324.  
  325.  
  326.                                             //Travel Agent Class
  327. class TravelAgent{
  328. private:
  329. char *name;
  330. list<Passenger> ListPassenger;      // Travel agent class has a collection of travellers and and collection of flight
  331. list<BusinessFlight> ListBusiness;
  332. list<EconomyFlight> ListEconomy;
  333.  
  334. public:
  335. void setName(char *InName);
  336. char* getName();
  337. void addEconomy(EconomyFlight objEcono);
  338. void addBusiness(BusinessFlight objBusiness);
  339. void addPassenger(Passenger objPassenger);
  340. void FlightList();
  341. void PassengerList();
  342. void DeleteFlight(int FlightNo);
  343. void UpdateFlight(int FlightNo);
  344. void UpdatePassenger(Passenger objPassenger);
  345. void DeletePassneger(int Pid);
  346.     void BookFlight(int PID , int FID);
  347. };
  348.  
  349. void TravelAgent::addEconomy(EconomyFlight objEcono){   // Add Economy Flight
  350. ListEconomy.push_back(objEcono);
  351. }
  352.  
  353. void TravelAgent::addBusiness(BusinessFlight objBusiness){    // Add Business 
  354. ListBusiness.push_front(objBusiness);
  355. }
  356.  
  357. void TravelAgent::addPassenger(Passenger objPassenger){
  358. ListPassenger.push_back(objPassenger);
  359. }
  360. //setter methods
  361. void TravelAgent::setName(char *InName){
  362. name= InName;
  363. }
  364. //getter methods
  365. char* TravelAgent::getName(){
  366. return name;
  367. }
  368.  
  369. void TravelAgent::FlightList(){     // List All flight Method
  370. cout<<"ID"<<setw(10)<<"Orgin"<<setw(20)<<"Destination"<<setw(10)<<"Date"<<setw(10)<<"Price\n";
  371. list<BusinessFlight>::iterator dis;
  372. for(dis=ListBusiness.begin(); dis!=ListBusiness.end();dis++){
  373. BusinessFlight b = *dis;
  374.  
  375. cout<<b.GetflightNo()<<setw(10)<<b.GetOrgin()<<setw(20)<<b.GetDesti()<<setw(10)<<b.GetDate()<<setw(10)<<b.GetPrice()
  376.  
  377. <<"\n";
  378. }
  379. list<EconomyFlight>::iterator itrEcon;
  380. for(itrEcon=ListEconomy.begin();itrEcon!=ListEconomy.end();itrEcon++){
  381. EconomyFlight e = *itrEcon;
  382. cout<<e.GetflightNo()<<setw(10)<<e.GetOrgin()<<setw(20)<<e.GetDesti()<<setw(10)<<e.GetDate()<<setw(10)<<e.GetPrice()
  383.  
  384. <<"\n";
  385. }
  386.  
  387. }
  388.  
  389. void TravelAgent::PassengerList(){    //  Method to list all Passengers
  390. cout<<"Booking id"<<setw(10)<<"Name"<<setw(20)<<"No Adult"<<setw(10)<<"No of Child"<<setw(10)<<"Price\tFlightID\n";
  391. list<Passenger>::iterator itrPasn;
  392. for(itrPasn=ListPassenger.begin(); itrPasn!=ListPassenger.end();itrPasn++){
  393. Passenger p = *itrPasn;
  394. cout<<p.getBookingRef()<<setw(10)<<p.getName()<<setw(20)<<p.getNumAdult()<<setw(10)<<p.getNumChildren()<<setw
  395.  
  396. (10)<<p.getTotalPrice()<<"\t"<<p.getNumFlight()<<"\n";
  397. }
  398. }
  399.  
  400. void TravelAgent::DeleteFlight(int FlightNo){          // Method to delete a flight
  401. list<BusinessFlight>::iterator dis;
  402. list<BusinessFlight>::iterator currentpos;
  403. int flag =0;
  404. for(dis=ListBusiness.begin(); dis!=ListBusiness.end();dis++){
  405. BusinessFlight b = *dis;
  406. int myFli = b.GetflightNo();
  407. if(FlightNo == myFli ){
  408. currentpos = dis;
  409. flag = 1;
  410. }
  411. }
  412.  
  413. list<EconomyFlight>::iterator itrEcon;
  414. list<EconomyFlight>::iterator EconCurrent;
  415. for(itrEcon=ListEconomy.begin(); itrEcon!=ListEconomy.end();itrEcon++){
  416. EconomyFlight e = *itrEcon;
  417. int myFli = e.GetflightNo();
  418. if(FlightNo == myFli ){
  419. EconCurrent = itrEcon;
  420. flag = 2;
  421. }
  422. }
  423.  
  424. if (flag==1){
  425. char ch;
  426. cout << "Do you want Delete Flight " << FlightNo << " :";
  427. cin >> ch;
  428. if(ch=='y'||ch=='Y'){
  429. ListBusiness.erase(currentpos);
  430. cout <<"Deleted......." <<endl;
  431. }
  432. }else{
  433. cout << "Could not found !!!!!"<<endl;
  434. }
  435.  
  436. if (flag==2){
  437. char ch;
  438. cout << "Do you want Delete Flight " << FlightNo << " :";
  439. cin >> ch;
  440. if(ch=='y'||ch=='Y'){
  441. ListEconomy.erase(EconCurrent);
  442. cout <<"Deleted......." <<endl;
  443. }
  444. }else{
  445. cout << "Could not found !!!!!"<<endl;
  446. }
  447. }
  448.  
  449. void TravelAgent::DeletePassneger(int PID){        // method to delete a passenger
  450. list<Passenger>::iterator itrPas;
  451. list<Passenger>::iterator currentpos;
  452. int flag =0;
  453. for(itrPas=ListPassenger.begin(); itrPas!=ListPassenger.end();itrPas++){
  454. Passenger p = *itrPas;
  455. int myFli = p.getBookingRef();
  456. if(PID == myFli ){
  457. currentpos = itrPas;
  458. flag = 1;
  459. }
  460. }
  461.  
  462.  
  463. if (flag==1){
  464. char ch;
  465. cout << "Do you want Delete Passenger " << PID << " :";
  466. cin >> ch;
  467. if(ch=='y'||ch=='Y'){
  468. ListPassenger.erase(currentpos);
  469. cout <<"Deleted......." <<endl;
  470. }
  471. }else{
  472. cout << "Could not found !!!!!"<<endl;
  473. }
  474.  
  475. }
  476.  
  477. void TravelAgent::BookFlight(int PID , int FID){     // Method to book a flight
  478.  
  479. list<Passenger>::iterator itrPas;
  480.  
  481. Passenger PC ;
  482. int flag =0;
  483. for(itrPas=ListPassenger.begin(); itrPas!=ListPassenger.end();itrPas++){
  484. Passenger p = *itrPas;
  485. int myFli = p.getBookingRef();
  486. if(PID == myFli ){
  487.  
  488. PC = *itrPas;
  489. flag = 1;
  490. }
  491. }
  492.  
  493.  
  494. list<BusinessFlight>::iterator dis;
  495.  
  496. BusinessFlight BC;
  497.  
  498.  
  499. for(dis=ListBusiness.begin(); dis!=ListBusiness.end();dis++){
  500. BusinessFlight b = *dis;
  501. int myFli = b.GetflightNo();
  502. if(FID == myFli ){
  503.  
  504. BC = *dis;
  505. flag = 1;
  506. }
  507. }
  508.  
  509. list<EconomyFlight>::iterator itrEcon;
  510.  
  511. EconomyFlight EC;
  512. for(itrEcon=ListEconomy.begin(); itrEcon!=ListEconomy.end();itrEcon++){
  513. EconomyFlight e = *itrEcon;
  514. int myFli = e.GetflightNo();
  515. if(FID == myFli ){
  516.  
  517. EC  = *itrEcon;
  518. flag = 2;
  519. }
  520. }
  521.  
  522. if (flag==1){
  523.  
  524. for(itrPas=ListPassenger.begin(); itrPas!=ListPassenger.end();itrPas++){
  525. Passenger p = *itrPas;
  526. int myFli = p.getBookingRef();
  527. if(PID == myFli ){
  528.  
  529. *itrPas = BC.Book(PC);
  530.  
  531. }
  532. }
  533. }
  534.  
  535. if (flag==2){
  536.  
  537. for(itrPas=ListPassenger.begin(); itrPas!=ListPassenger.end();itrPas++){
  538. Passenger p = *itrPas;
  539. int myFli = p.getBookingRef();
  540. if(PID == myFli ){
  541.  
  542. *itrPas = EC.Book(PC);
  543.  
  544. }
  545. }
  546. }
  547. }
  548. // Method to update Flight Information
  549. void TravelAgent::UpdateFlight(int FlightNo){  
  550.  
  551. list<BusinessFlight>::iterator dis;
  552. list<BusinessFlight>::iterator currentpos;
  553.  
  554. for(dis=ListBusiness.begin(); dis!=ListBusiness.end();dis++){
  555. BusinessFlight b = *dis;
  556. int myFli = b.GetflightNo();
  557. if(FlightNo == myFli ){
  558. currentpos = dis;
  559. // update the  attributes of flights 
  560.  
  561. }
  562. }
  563.  
  564. }
  565.  
  566.  
  567. // Method to update Passenger Information
  568. void TravelAgent::UpdatePassenger(Passenger objPassenger){           
  569.  
  570.  
  571. }
  572.  
  573.  
  574.                                                 //Travel Console
  575.  
  576. class TravelConsole{
  577. private:
  578. BusinessFlight *objBusiness;
  579. EconomyFlight *objEconomy;
  580. Flight* objFlght;
  581. Movie *objMovie;
  582. TravelAgent objAgent;
  583. public:
  584. void CreateBusinessFlight();
  585. void CreateEconomyFlight();
  586. void CreateMovie();
  587. void ListFlight();
  588. void CreatePassenger();
  589. void DeleteFlight();
  590. void DeletePassenger();
  591. void Booking();
  592. TravelAgent getTravelAgent();
  593. };
  594. // 
  595. TravelAgent TravelConsole::getTravelAgent(){
  596. return objAgent;
  597. }
  598. // Create Business Flight
  599. void TravelConsole::CreateBusinessFlight(){                            // flight no  to appear automatically
  600. char orgin[75];
  601. char destination[60];
  602. char date[60];
  603. char deparr[60];
  604. double price;
  605. int childPercentage;
  606. double rate;
  607. cout<<"Business Flight Detail"<<endl;
  608. cout <<"-------------------------------------"<<endl;
  609. cout << "Enter the Flight Origin  :"<<endl;
  610. cin >> orgin;
  611. cout << "Enter the Flight Destination    :"<<endl;
  612. cin >> destination;
  613. cout << "Enter Flight Date (in the format  :  00/00/000) :"<<endl;
  614. cin >> date;
  615. cout << "Enter the Depar and Arrival Time (dep 1:00 , arr 3:00):";
  616. cin >> deparr;
  617. cout << "Enter the Price ($) :" <<endl;
  618. cin >> price;
  619. cout << "Enter the Child Percentage(%) :"<<endl;
  620. cin >> childPercentage;
  621. cout << "Enter the Rate :"<<endl;
  622. cin >> rate;
  623. BusinessFlight obiBussin;
  624. obiBussin.SetOrgin(orgin);
  625. obiBussin.SetDesti(destination);
  626. obiBussin.SetDate(date);
  627. obiBussin.SetDeparr(deparr);
  628. obiBussin.SetPrice(price);
  629. obiBussin.SetChildPerc(childPercentage);
  630. obiBussin.SetRate(rate);
  631. objAgent.addBusiness(obiBussin);
  632. char ch;
  633. char no='y';
  634. cout <<"Do you want add Movie to this Flight (Y/N) :";
  635. cin >>ch;
  636. if(ch=='y'||ch=='Y'){
  637. while(no!='n'){
  638. CreateMovie();
  639. cout <<"Movied added" <<endl;
  640. cout <<"Do you add another Movie (Y/N) :";
  641. cin >> no;
  642. };
  643. }
  644.  
  645. }
  646. // Create Economy Flight
  647. void TravelConsole::CreateEconomyFlight(){
  648. int flightNo;
  649. char orgin[30];
  650. char destination[30];
  651. char date[30];
  652. char deparr[50];
  653. double price;
  654. int childPercentage;
  655.  
  656.  
  657. flightNo=0;
  658.   flightNo++;
  659. cout<<"Economy Flight Detail"<<endl;                                 // flight no to appear automatically
  660. cout <<"-------------------------------------"<<endl;
  661. cout << "Enter the Flight Origin  :"<<endl;
  662. cin >> orgin;
  663. cout << "Enter the Flight Destination :"<<endl;
  664. cin >> destination;
  665. cout << "Enter Flight Date  (in the format  :  00/00/000) :"<<endl;
  666. cin >> date;
  667. cout << "Enter the Depar and Arrival Time (dep 1:00 , arr 3:00) :"<<endl;
  668. cin >> deparr;
  669. cout << "Enter the Price($) :" <<endl;
  670. cin >> price;
  671. cout << "Enter the Child Percentage(%) :"<<endl;
  672. cin >> childPercentage;
  673.  
  674.  EconomyFlight economyFlight;
  675.  
  676. economyFlight.SetOrgin(orgin);
  677. economyFlight.SetDesti(destination);
  678. economyFlight.SetDate(date);
  679. economyFlight.SetDeparr(deparr);
  680. economyFlight.SetPrice(price);
  681. economyFlight.SetChildPerc(childPercentage);
  682. objAgent.addEconomy(economyFlight);
  683.  
  684. char ch;
  685. cout <<"Do you want add Movie to this Flight (Y/N) :";
  686. cin >>ch;
  687. if(ch=='y'||ch=='Y'){
  688. CreateMovie();
  689. cout <<"Movied added" <<endl;
  690. }
  691. }
  692. // Add a Passenger
  693. void TravelConsole::CreatePassenger(){
  694. int bookingRef;
  695. char name[50];
  696. int numAdult;
  697. int numChild;
  698. int numFlight;
  699. double totalPrice;
  700.  
  701. cout<<"Create Person"<<endl;
  702. cout <<"-------------------------------------"<<endl;
  703. cout << "Enter the Name:";
  704. cin >> name;
  705. cout << "Enter Number of Adult :";
  706. cin >> numAdult;
  707. cout << "Enter Number of Children:";
  708. cin >> numChild;
  709. Passenger objPasn;
  710. objPasn.setName(name);
  711. objPasn.setNumAdult(numAdult);
  712. objPasn.setNumChildren(numChild);
  713. objPasn.setNumFlight(0);
  714. objPasn.setTotalPrice(0.0);
  715. objAgent.addPassenger(objPasn);
  716. }
  717. // Add a movie
  718. void TravelConsole::CreateMovie(){
  719. char title [40];
  720. cout<<"Create Flight"<<endl;
  721. cout <<"-------------------------------------"<<endl;
  722. cout << "Enter Movie Name  :";
  723. cin >> title;
  724. objMovie = new Movie(title);
  725. }
  726. // Delete a Flight
  727. void TravelConsole::DeleteFlight(){
  728. int FID;
  729. cout << "Please Enter the Flight No :";
  730. cin >> FID;
  731. objAgent.DeleteFlight(FID);
  732. }
  733. // Delete a Passenger
  734. void TravelConsole::DeletePassenger(){
  735. int PID;
  736. cout << "Please Enter the Passenger ID:";
  737. cin >> PID;
  738. objAgent.DeletePassneger(PID);
  739. }
  740.  
  741. void TravelConsole::Booking(){
  742. int PID;
  743. int FID;
  744.  
  745. objAgent.PassengerList();
  746. cout << "Select A Passenger :";
  747. cin >> PID;
  748. objAgent.FlightList();
  749. cout << "Select A Select a Flight:";
  750. cin >> FID;
  751. objAgent.BookFlight(PID,FID);
  752. }
  753.  
  754. //  MAIN MENU 
  755.  
  756. int main(){
  757.  
  758. TravelConsole Journey;
  759. int menu;
  760.  
  761. do{
  762. cout << "----------------------" <<endl;
  763. cout << "        MAIN MENU    " << endl;
  764. cout << "----------------------" <<endl;
  765. cout<<endl;
  766. cout<<endl;
  767.  
  768. cout <<"1. Add Business Flight " <<endl;
  769. cout <<"2. Add Economy Flight " <<endl;
  770. cout <<"3. Delete Flight " << endl;
  771. cout <<"4. Flight List " << endl;
  772. cout <<"5. Create Passenger " <<endl;
  773. cout <<"6. Passenger list " <<endl;
  774. cout <<"7. Delete Passenger " << endl;
  775. cout <<"8. Booking " << endl;
  776. cout<<" 9. Update Flight Information"<<endl;        // -----------------------> update flight
  777. cout<<"10. Update Passenger Information"<<endl;     // -------------------------> update passenger
  778. cout <<"9. Exit " << endl;
  779. cout <<"" << endl;
  780. cout <<"Please Select a Choice: " <<flush;
  781. cin >>menu;
  782.  
  783. switch(menu){
  784. case 1: {    
  785. Journey.CreateBusinessFlight();
  786. break;
  787. }
  788. case 2: {
  789. Journey.CreateEconomyFlight();
  790. break;
  791. }
  792.  
  793. case 3:{
  794. Journey.DeleteFlight();
  795. break;
  796.   }
  797. case 4:{
  798.  
  799. Journey.getTravelAgent().FlightList();
  800. break;
  801.   }
  802. case 5:{
  803. Journey.getTravelAgent().PassengerList();
  804. break;
  805.   }
  806. case 6:{
  807. Journey.CreatePassenger();
  808.  
  809. break;
  810.   }
  811. case 7:{
  812. Journey.DeletePassenger();
  813. break;
  814.   }
  815. case 8:{
  816. Journey.Booking();
  817. break;
  818.   }
  819. case 9:{
  820. return 0;
  821. break;
  822.   }
  823. }
  824.  
  825.  
  826. }while(menu!=10);
  827.  
  828. getchar();
  829. system("pause");
  830. return 0;
  831. }
  832.  
  833.  
  834.  
-----------------------------------------

above is a the code for my program TravelConsole
It contains function for adding flights , deleting flight and etc. ------------------------------------------
Additionally I need to implement and edit function..An edit function to allow users to change details of any object.


-Display an itinerary for a passenger. To do this, a list of flight numbers (that the passenger is booked on) will need to be stored with the passenger information. Flights should be displayed in chronological order.

-When booking flights, if there is a date conflict with an existing flight, prompt the user to change the date on one of the flights.


Any help is appreciated!!
Dec 7 '16 #1
2 1785
A quick response is needed as I have to submit this by tonight.
Dec 7 '16 #2
weaknessforcats
9,208 Expert Mod 8TB
What is your question exactly?

You update an array element by:

Expand|Select|Wrap|Line Numbers
  1. arr[10] = 5;
  2.  
Yu update a vector element by:

Expand|Select|Wrap|Line Numbers
  1. vec[10] = 5;
vector<> replaces an array. plus there are a lot of things you can do with a vector that require a ton of code if you use an array.

I need more info on what your problem is.

I still see char* in the code. Why can't you use a C++ string object?
Dec 7 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Al Newton | last post by:
I want to use STL's sort algorithm to sort a string vector. Some of the strings are fairly long (300 to 400 chars) and the vector isn't small (5,000 to 10,000 elements). Naturally, sorting time...
0
by: Newsgroup - Ann | last post by:
Hi: I saw the following codes from the FAQ about the contiguous storage of vector. I am just wondering how does the implementation of the <vector> guarantee the contiguous? What if a vector v...
14
by: Roland Bengtsson | last post by:
I have a class Conception and I have this in a vector, it should be: vector<Conception> vek; // vector vector<Conception>::iterator vek; // iterator to vek But what if I want to have pointers...
8
by: Joseph Turian | last post by:
Fellow hackers, Is it possible to shrink the capacity of a vector? i.e. Without new'ing and delete'ing a vector, can one return its memory to the heap? Here's what I get under the g++...
34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
6
by: Roman Töngi | last post by:
I want to change a vector in a function. I pass a pointer of it to the function and append an item. Then I want to print the first item in the vector. It doesn't work. Can anyone help me? Thanks...
8
by: wg | last post by:
I have worked on this for a while and have not been able to get it working. I seem to be missing something. What I am attempting to do is get information from a csv file such as: name (stirng),...
82
by: Peter Olcott | last post by:
I need std::vector like capability for several custom classes. I already discussed this extensively in the thread named ArrayList without Boxing and Unboxing. The solution was to simply create...
32
by: T. Crane | last post by:
Hi, I'm struggling with how to initialize a vector<vector<double>> object. I'm pulling data out of a file and storing it in the vector<vector<double>object. Because any given file will have a...
3
by: thomas | last post by:
I want to use a priority_queue like STL data structure. But I found that priority_queue cannot update element value: only pop/ push is supported. I'm using priority_queue to implement the prim...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.