![]() |
| ||
| Re: airplane seating prices Hi, This is my complete code: //Airplanes Seating Allocation System yeah, I'm aware that's it's a bit (ok, a lot) messy. But since I'm a beginner, I don't know how to take any other shortcuts. Can you take a look at the DisplayPrices() and the PurchaseTickets() functions? I post my questions there as well. thanks a lot, Karen |
| ||
| Re: airplane seating prices I looked at your code. It really could benefit from a rewrite. I got this far then had to go out so rest left as exercise for you. see how you do. Post later what you come up with and ill look it over. // You have shown enough effort for me to help you rewrite thisYou will still need to write the bits I left as an exercise and also add any more functions you deem necessary. Its reasonably simple stuff but some of it you may not have come across yet. Try follow whats been done so far. It should be reasonably easy for you to finish it off. |
| ||
| Re: airplane seating prices OMG! You're asking me to rewrite my code, which I've spent days (over a week already) doing. Please don't be that cruel. i'm only a beginner and I've slaved over this project so much I can't bear to start over again. I looked over the code that you're written so far...and to be honest...I can follow it but I can't do that on my own...I have no idea what to do next! Can you please just help me with my code? with the parts where I got stuck on? Please? Right now, I've rewritten parts of it. and there is one mistake that I should mention. There are only 3 types of seats: leg room, Window, and aisle seats. There are no "regular seats" because airplanes have windows on both sides *duh*. My modification: the DisplaySeats() and the DisplayPrices() functions. My Problem: the PurchaseTicket() and the DisplaySales() functions. Since each type of seat has different prices, I've trying to ask for the user to enter the seattype and then the row and the seat numbers. I'm only able to code the program to ask for the row and seat numbers. Can you tell me what's wrong with my DisplayPrices() function? Why doesn't display anything when I tested it?
I'm so sorry I'm not any brighter at this. It's really hard to learn this stuff. Karen |
| ||
| Re: airplane seating prices You should really try to finish my code. I can help you so dont panic. There was too many errors in your original code to make it worthwhile to fix rather than rewrite. Also your design doesn't lend to code brevity. Notice in mine all the data you need to do any calculations is all stored in an array of structs. I gave in the comments a little info on structs, certainly enough for you to be able to grasp what i had written. Notice how it makes things easy and cuts down in general on the amount of loops you need to write.It enhances code readability and therefore makes it easier for you to understand.If there is any part of my code you dont understand just point it out and ill help. Try first to write the AllocSeat function. You ask for wanted seattype. You can then iterate the array for the first of that seattype whose taken member is also false. Set taken to true or call Sorry() and that ones done. There is a few examples of iterating that array of structs already in the code so that shouldn't phase you. There are also examples of comparing strings and assigning struct members. Most of the code is already written for you. Theres only a few funcs to add and maybe one or two to add a line to. Dont put yourself down for not being bright. I know quite a few people who describe themselves in that manner and some of those are very good coders. Slow and steady is better than fast and falling flat on your face. C++ is hard to learn, I wont lie to you but its not impossible to grasp the simple constructs I have shown you here. std::strings are a much easier type to work with than char array strings and should be taught before the latter. There is enough information in the code to allow you to use the struct array confidently. loops ifs and function calls are about all you need. If you can follow what I have written then you can finish it. I'll be around for about 4 hrs from time of this post. |
| ||
| Re: airplane seating prices OK, I took your advice and gave it a try. void AllocSeat(string type) This is my best (miserable) attempt. |
| ||
| Re: airplane seating prices now compare yours with mine. Ive changed a couple of things, displaying now displays row and seatnumbers. Sorry has gone. There are 2 overloads of AllocSeat. one lets you pick a specific seat and another a type of seat. Have you covered overloading of functions yet? Starting to see how this is coming together? // You have shown enough effort for me to help you rewrite this |
| ||
| Re: airplane seating prices Ok, I've compared yours with mine and they're not EVEN close to being similar to each other. I don't understand why you have 2 AlloSeat() functions, are you allowed to do that? How do we know which function to use in the main function? And no, I've learned about overloading functions yet. |
| ||
| Re: airplane seating prices OMG! My final (for another class) is in 30 min! I have to go to that class! When will you be gone? This airplane project is due tomorrow, cause tomorrow is my final in this C++ class! |
| ||
| Re: airplane seating prices yes you are allowed to do that its called function overloading. If we called it like this... string s="legroom"; AllocSeat(s); then the one that takes a string will be called. This will automatically search for the first available seat of that type and allocate it. I should have added a message telling you seatnumber and row, you can do that i am sure. Alternatively if we call it like so int row,seatnum; cout<<"enter row and seatnumber separated by a space"<<endl; cin>>row>>seatnum; AllocSeat(row,seatnum); then that overload will try to take the specific seat pointed at by row/seatnum. So you should now be able to write a function that asks user whether he would like to pick a seat or auto get one and call the correct overload of AllocSeat. Again dont panic, I know this is due soon but we will get it done and my hope is I teach you a little something on the way too. |
| ||
| Re: airplane seating prices maybe 2.5 hrs more. then 8 hrs sleep then on for a bit before work over brekkies. |
| All times are GMT -4. The time now is 8:56 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC