C++

I am writing a program to reserve tennis courts. The system needs to be able to recall the reservations that have already been made. I am having trouble with this. What do I need to do. Do you need more code?
inData.open("reservation.txt");
    outData.open("reservation.out");
 
I have code to select the courts and then member name etc. then
 inData.close();
 outData.close();
 
	return 0;
}

Open in new window

sendhelpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
>> I am having trouble with this. What do I need to do. Do you need more code?
Um yes, you've not really done much here have you? :)
0
sendhelpAuthor Commented:
here is my main. Do you need my header file too.
I did not want to post all of it. This is an assignment and someone in my class copied my last one and we both got a zero. I don't want that to happen again. They might not have copied it from here but in our tutor center at school, I just did not want to take chances of it happening again. Can I make this question not be in the knowledge base for others to see?
help.txt
0
evilrixSenior Software Engineer (Avast)Commented:
SO, what trouble are you having?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

sendhelpAuthor Commented:
For starters, I can't get the reservation to write to the file.

Do you need the header file and the assignment guidelines as well. Do you know if I keep posting txt files as attachments that if anyone can find this in the search engine?
0
evilrixSenior Software Engineer (Avast)Commented:
Ok... this is an assignment so the way this needs to work is you need to ask specific questions regarding what you are stuck on. The experts will give you tips and hints but you will need to figure this out yourself. So, this being the case, you need to tell us what specifically you cannot do or do not understand and we will do out best to point you in the right direction.
0
sendhelpAuthor Commented:
Even when I comment out the parts of code that are not working, I still cannot get my reservation to write to the file outData. I thought that I have done it correctly, but it won't work. I attached the txt file above, that is what I have. I just need guidance to make it write to the file. I don't know how to be more specific than this.
0
jkrCommented:
>>I still cannot get my reservation to write to the file outData

Your code is quite weird. In

     outData << setw(5)<< CourtNum
                  << setw(5)<< isMember
                  << setw(5)<< game
                  << setw(5)<< gametype
                << setw(5)<< stillAvail
                << startDate
                << endDate
                << personName
                << address
                << city
                << state
                << cardType
                << cardNum
                << expDate
                        <<endl;

you are writing data that *looks* like it is intended to be a member of "Courts" - yet it isn't a member of anything, at least syntactically. Nor is it declared anywhere.

Also, you have an array of "Courts". But, where's the loginc behind

      r[1].setCourtInfo("doubles", false, true, 1);
      r[2].setCourtInfo("singles", false, false, 2);
      r[3].setCourtInfo("doubles", true, true, 3);
      r[4].setCourtInfo("doubles", true, false, 4);
      r[5].setCourtInfo("singles", true, true, 5);
      r[6].setCourtInfo("doubles", false, true, 6);
    r[7].setCourtInfo("singles", false, true, 7);
      r[8].setCourtInfo("doubles", false, true, 8);
      r[9].setCourtInfo("singles", true, false, 9);
      r[10].setCourtInfo("doubles", false, true, 10);
      bool maderes = r[2].reserveCourt(3);

You are setting info on 10 objects (BTW, what happened to 'r[0]'?) and then call a methid of the 3rd element in 'r[2].reserveCourt(3);'? What's the logic behind that? Why not 'r[5].reserveCourt(42);'?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sendhelpAuthor Commented:
Your code is quite weird. In

     outData << setw(5)<< CourtNum
                  << setw(5)<< isMember
                  << setw(5)<< game
                  << setw(5)<< gametype
                << setw(5)<< stillAvail
                << startDate
                << endDate
                << personName
                << address
                << city
                << state
                << cardType
                << cardNum
                << expDate
                        <<endl;

you are writing data that *looks* like it is intended to be a member of "Courts" - yet it isn't a member of anything, at least syntactically. Nor is it declared anywhere.

Also, you have an array of "Courts". But, where's the loginc behind

      r[1].setCourtInfo("doubles", false, true, 1);
      r[2].setCourtInfo("singles", false, false, 2);
      r[3].setCourtInfo("doubles", true, true, 3);
      r[4].setCourtInfo("doubles", true, false, 4);
      r[5].setCourtInfo("singles", true, true, 5);
      r[6].setCourtInfo("doubles", false, true, 6);
    r[7].setCourtInfo("singles", false, true, 7);
      r[8].setCourtInfo("doubles", false, true, 8);
      r[9].setCourtInfo("singles", true, false, 9);
      r[10].setCourtInfo("doubles", false, true, 10);
      bool maderes = r[2].reserveCourt(3);
 I have that commented out for my code to work. I have to be able to reserve ten courts over a one month period. Even with the code commented out, it still is not writing to the file. The part to choose which court etc. I can get it to work, just not write to file, I think I might be able to work the rest of this out, but I don't know about the outData. If you don't pay attention to this data, can you give me suggestions on making the outData to work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.