• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

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

0
sendhelp
Asked:
sendhelp
  • 4
  • 3
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now