Присвойте имя месту и отобразите в массиве

У меня проблема с назначением пользователей массиву и последующему отображению массива. Типичная программа «назначение места для полета». Любая помощь была бы фантастической, так как я серьезно застрял.

Я не получаю никаких ошибок при компиляции, поэтому я предполагаю, что я не слишком далеко? код следующим образом.

Обратите внимание, классы в отдельных заголовочных файлах.

// Flight Class - Scotia 2
// Contains information on seating (array), space available and return to menu option.
#include <iostream>
#include <string>
#include "booking.h"
using namespace std;

class Flight
{

public:

public:
struct Seat
{
int Available;
string fullName;
};// End of struct

// Structure for seat plan (24 spaces available)
struct Seat seatArray[4][6];

void seatPlan()
{   //------
cout << "Scotia Airlines Seating Plan\n";
cout << "------------------------\n";
cout << " 1D  2D  3D  4D  5D  6D\n";
cout << " 1C  2C  3C  4C  5C  6C\n";
cout << "                       \n";
cout << " 1B  2B  3B  4B  5B  6B\n";
cout << " 1A  2A  3A  4A  5A  6A\n";
cout << "------------------------\n\n\n";
//------
for (int i=0;i<4;i++)
{
for (int j=0;j<6;j++)
{
if (seatArray[i][j].Available == 0)
cout << seatArray[i][j].fullName << "=" << i+1;

else
cout << "Seating Plan is unavailable";
break;
}
}// End of for loop
}// End of seatPlan function

};// End of Flight class

Вот мой класс бронирования, так как я уверен, что это поможет выявить проблему …

//Booking class - Scotia Airlines
//This class will reserve a seat for passenger

#include <iostream>
#include <string>

using namespace std;

class Booking{

public:
struct Seat
{
int Available;
string fullName;
};// End of struct

// Structure for seat plan (24 spaces available)
struct Seat seatArray[4][6];

//variables for taking in customer details, calculating ticket cost (inc discounts) and adding details to system
public:
string fName, sName, busName, fullName;
int age, livesAt;
float discount, tickPrice, tCost;

void addBooking()

{
cout << "\tBooking Menu \n\n";
cout << "Please select ticket type: \n";
cout << "1- Business \n";
cout << "2- Western Isles \n";
cout << "3- Ordinary \n";
cin >> livesAt;

// This will be used to calc total cost for each passenger dependant on ticket type
if(livesAt == 1)
{
discount = 0.75;
cout << "Please enter your business name\n";
cin >> busName;
}

else if (livesAt == 2)
{
discount = 0.90;
}

else
{
discount = 1.0;
};

// Calculation - Standard ticket price is 60 Beans
tickPrice = 60.0;
tCost = (tickPrice * discount);bool booked = false;
for(int i = 0; i < 4 && !booked; i++)
{
for(int j = 0; j < 6 && !booked; j++)
{
if(seatArray[i][j].Available == 1)
{
cout << "Please enter your first name \n";
cin >> fName;
cout << "Please enter your second name \n";
cin >> sName;
fullName == fName + " " + sName;
seatArray[i][j].fullName = fullName;
booked = true;
// Message on screen for customer displaying cost of flight
cout << "*******************************\n";
cout << "\tBooking for " << fName + " " + sName << " confirmed.\n";
cout << "\tTotal cost = " << tCost << " GBP.\n";
}//end of if
}//end of for2
}//end of for1}// End of addBooking function
};// End of Booking class

Любая помощь будет принята с благодарностью!

-2

Решение

Вот некоторые ошибки, которые я обнаружил:

  1. Прежде всего, вы никогда не помечаете место как недоступное. Добавьте это к вашей дополнительной функции Booing.
  2. Второе, остальное во втором, потому что в seatPlan должно быть в другом, я верю.
  3. Вам не нужна точка с запятой после оператора else (в else при установке скидки на 1.0)

Поскольку вы никогда не упоминаете, какие ошибки вы получаете, это настолько хорошо, насколько я могу получить. Надеюсь, этот ответ поможет.

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector