Can someone explain this to me please...

This is part of a cinema project code that my friend did. I understand most of the other parts, but when I came to this part, I am completely lost.
Can someone please explain this to me line by line please.

Thank You.

If you need the complete code to understand ,I'll upload it....


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void Ticketing::ChooseSeat(int NumOfSeat,double sale)
{
    char Option[256]={0};
    string Input="";
    char SeatY[1];
    int SeatX;
    int FinalSeatY=0;
    char CInput[256]={0};
    cout << "\nChoose Seat : ";
    getline (cin,Input);
    for (int i=0;i<Input.size();i++)CInput[i]=Input[i];
    cout << "Action('o' for reserved and 'x' for direct payment) : ";
    getline (cin,Input);
    for (int i=0;i<Input.size();i++)Option[i]=Input[i];
    sscanf ( CInput, "%c %d",SeatY , &SeatX);//http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/
    SeatY[0]=toupper(SeatY[0]);
    Option[0]=toupper(Option[0]);
    FinalSeatY = int(SeatY[0]-65);//get integer value of a char to goto array's y index
    int temp = NumOfSeat+SeatX;
    for (;SeatX<temp;SeatX++)
    {
        seat[SeatX-1][FinalSeatY] = Option[0];
    }
    if (Option[0]=='X')UpdateCash(NumOfSeat,sale);
}

Last edited on
Just formatting the code so I can read it better.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
void Ticketing::ChooseSeat(int NumOfSeat,double sale)
{
   char Option[256]={0};
   string Input="";
   char SeatY[1];
   int SeatX;
   int FinalSeatY=0;
   char CInput[256]={0};

   cout << "\nChoose Seat : ";
   getline (cin, Input);
   for (int i = 0; i < Input.size(); i++)
      CInput[i] = Input[i];

   cout << "Action('o' for reserved and 'x' for direct payment) : ";
   getline (cin, Input);

   for (int i=0;i<Input.size();i++)
      Option[i] = Input[i];

   sscanf (CInput, "%c %d", SeatY, &SeatX);//http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/
   SeatY[0] = toupper(SeatY[0]);
   Option[0] = toupper(Option[0]);
   FinalSeatY = int(SeatY[0] - 65);//get integer value of a char to goto array's y index

   int temp = NumOfSeat + SeatX;
   for (; SeatX<temp; SeatX++)
      seat[SeatX-1][FinalSeatY] = Option[0];

   if (Option[0]=='X')
      UpdateCash(NumOfSeat,sale);
}


O.o
Last edited on
Topic archived. No new replies allowed.