Question

In: Computer Science

You are assigned to implement the following baggage-check-in system at the airport. The system keeps track...

You are assigned to implement the following baggage-check-in system at the airport.

The system keeps track of data for the following information: passenger, bags, and tickets.

The program must maintain passenger details like name, address, phone number, and the number of bags. Each passenger can have multiple bags and each bag has length, width, height, and weight. The passenger also has a ticket. The tickets are of two types, either a first-class ticket or an economy-ticket. The maximum weight allowed for a first-class ticket is 40 Kilos and the maximum weight allowed for an economy-ticket is 30 Kilos. The program must display all the details of the passenger, ticket, and number of bags and allowed weight. If the weight exceeds that of the respective ticket class, then the program will give appropriate message to indicate that the passenger cannot travel. Your program must throw an exception to indicate the failure.

Requirements

  • Implement the following functions:
    1. checkOverweigth() # Given the ticket number, check if the total weight of all bags exceeds limit
    2. checkPassengerClass() # Given the ticket number, the class of the ticket is given
    3. displayPassengerDetails() # Given the ticket number, display all check-in details of a passenger
  • Student is required to identify classes, related attributes, and behaviors. Students are free to add as many attributes as required. The appropriate access modifiers (private, public, or protected) must be used while implementing class relationships. Proper documentation of code is mandatory.
  • Student must also test the code, by creating at-least three objects. All classes must have a display function, and the program must have functionality to print current state of the objects.

Solutions

Expert Solution

bag.h


#include<iostream>
#include<conio.h>
#include<string.h>
using namespace std;

class bag_check_system
{
private:
   char name[25];
   string address;
   string phn_no;
   int no_bags[20];
   int bag_len;
   int bag_weight;
   int bag_hei;
   int ticket_no;
   int no;

public:
   bag_check_system();
   void checkOverweigth();
   string checkPassengerClass();
   void displayPassengerDetails();
   void accept();


   const char* getName();
   string getAddress();
   string getPhn_no();
   int getNo_bags();
int getBag_len();
int getBag_wei();
int getBag_hei();
int getNo();
int getTicket_no();

void setName(const char*);
void setAddress(string);
void setPhn_no(string);
void setNo_bags(int);
void setBag_len(int);
void setBag_wei(int);
void setBag_hei(int);
void setNo(int);
void setTicket_no(int);

};

bag.cpp

#include"bag.h"

bag_check_system:: bag_check_system()
{


strcpy(this-> name,"\0");
this->address="\0";
this->phn_no="\0";
//this->no_bags=null;
this->bag_len=0;
this->bag_weight=0;
this->bag_hei=0;

this->ticket_no=0;
this->no=0;

}

void bag_check_system::setName(const char* name )
{
   strcpy(this->name,name);
}
void bag_check_system::setAddress(string address)
{
   this->address=address;
}
void bag_check_system::setPhn_no(string phn_no)
{
   this->phn_no=phn_no;
}

void bag_check_system::setBag_len(int bag_len)
{
   this->bag_len=bag_len;
}
void bag_check_system::setBag_hei(int bag_hei)
{
   this->bag_hei=bag_hei;
}

void bag_check_system::setBag_wei(int bag_weight)
{
   this->bag_weight=bag_weight;
}

int bag_check_system::getTicket_no()
{
return this->ticket_no;
}


const char* bag_check_system::getName()
{
   return this->name;
}

string bag_check_system::getAddress()
{
   return this->address;
}
string bag_check_system::getPhn_no()
{
   return this->phn_no;
}

int bag_check_system::getBag_len()
{
   return this->bag_len;
}
int bag_check_system::getBag_hei()
{
   return this->bag_hei;
}
int bag_check_system::getBag_wei()
{

for(int i=1;i<=no;i++)
{
this->bag_weight=this->bag_weight+no_bags[i];

}
   return this->bag_weight;
}


void bag_check_system::checkOverweigth()
{

if(this->checkPassengerClass()=="First Class")
{

if(this->getBag_wei() <=40)
{
cout<<"Weight of bags is: "<<this->getBag_wei();
cout<<"Bags are allowed in the plane";
}
else
{
cout<<"Decrease the weight below 40kg";
}

}
else if(this->checkPassengerClass()=="Economy class")

{
if(this->getBag_wei() <=30)
{
cout<<"Weight of bags is: "<<this->getBag_wei();
cout<<"Bags are allowed in the plane";
}
else
{
cout<<"Decrease the weight below 40kg";
}
}
}

string bag_check_system::checkPassengerClass()
{
if(this->ticket_no >0 &&this->ticket_no <=50)
{
cout<<"First class" ;
return "First class";
}
if(this->ticket_no >50&& this->ticket_no <=150)
{
cout<<"Economy class" ;
return "Economy class";
}


}
void bag_check_system::accept()
{

cout<<"enter Passenger Name: "<<endl;
   cin>>this->name;

   cout<<"enter Address: "<<endl;
   cin>>address;

   cout<<"enter Phone no: "<<endl;
   cin>>phn_no;


   cout<<"enter Number of Bags: "<<endl;
   cin>>no;

   no_bags[no];

for(int i=1;i<=no;i++)
{
cout<<"enter Weight of bag "<<i<<": "<<endl;
cin>>no_bags[i];
}
cout<<"Enter Ticket NO.: "<<endl;
cin>>this->ticket_no;

}

void bag_check_system::displayPassengerDetails()
{

cout<<"Passenger Name: "<<name<<endl;
   cout<<"enter Address: "<<address<<endl;
cout<<"Phone no: "<<this->phn_no<<endl;
cout<<"Ticket no: "<<this->ticket_no<<endl;
   cout<<"Number of Bags: "<<this->no<<endl;
   cout<<"Weight of bag/s is: "<<this->getBag_wei()<<endl;


}

main.cpp

#include "bag.h"

using namespace std;

int main()
{
bag_check_system bag;

bag.accept();
cout<<"Details of Passenger are: "<<endl;
bag.displayPassengerDetails();

bag.checkPassengerClass();

bag.checkOverweigth();
_getch();
return 0;

}


Related Solutions

create a python program You are assigned to implement the following baggage-check-in system at the airport....
create a python program You are assigned to implement the following baggage-check-in system at the airport. The system keeps track of data for the following information: passenger, bags, and tickets. The program must maintain passenger details like name, address, phone number, and the number of bags. Each passenger can have multiple bags and each bag has length, width, height, and weight. The passenger also has a ticket. The tickets are of two types, either a first-class ticket or an economy-ticket....
Create a program that keeps track of the following information input by the user: First Name,...
Create a program that keeps track of the following information input by the user: First Name, Last Name, Phone Number, Age Now - let's store this in a multidimensional array that will hold 10 of these contacts. So our multidimensional array will need to be 10 rows and 4 columns. You should be able to add, display and remove contacts in the array. In Java
The following class keeps track of how many flavors are at an ice-cream place, and the...
The following class keeps track of how many flavors are at an ice-cream place, and the number of calories of each flavor. The calories of each flavor ice-cream are positive values of type unsigned int and are stored as a dynamically allocated array. The first data member is a pointer that will point to the first element of the array. This array will be of an arbitrary size. The default size of the array shall be 25, but may be...
Auditing Questions 1) What do you call the type of organization that keeps track of another...
Auditing Questions 1) What do you call the type of organization that keeps track of another company's equity-related transactions? 2) What area do we always assume that risks of fraud exist and that if we do not assume, we need to document our conclusion? 3) What statistical distribution pertains to the Test of Controls? 4) What does PPC stand for? 5) Which publicly traded companies are required to have their internal control audited?
Evaluate the pros and cons of the following: Remaining with a government-operated system of administering airport...
Evaluate the pros and cons of the following: Remaining with a government-operated system of administering airport security, versus returning to privately owned and operated, contracted airport security organizations. In your evaluation, consider factors that resulted in the creation of the Transportation Security Administration. Includein your discussion San Francisco International Airport’s ability to remain secure while utilizing a private company under contract with the federal government. As always, draw upon previous module knowledge to help you conduct your analysis. Required pages:...
Please write a Java algorithm solving the following problem: Implement a Java method to check if...
Please write a Java algorithm solving the following problem: Implement a Java method to check if a binary tree is balanced. For this assignment, a balanced tree is defined to be a tree such that the heights of the two subtrees of any node never differ by more than one. 1. First, please create the following two classes supporting the Binary Tree Node and the Binary Tree: public class BinTreeNode<T> { private T key; private Object satelliteData; private BinTreeNode<T> parent;...
You were assigned to lead a project team to implement acceptance of patients enrolled under Obamacare....
You were assigned to lead a project team to implement acceptance of patients enrolled under Obamacare. Describe what steps you would take to implement this new plan and which stakeholders should be included in the project.
You have been assigned to implement a three-month hedge for a stock mutual fund portfolio that...
You have been assigned to implement a three-month hedge for a stock mutual fund portfolio that primarily invests in medium-sized companies. The mutual fund has a beta of 1.46 measured relative to the S&P Midcap 400, and the net asset value of the fund is $186 million. a. Should you be long or short in the Midcap 400 futures contracts? Long Short b. Assuming the Midcap 400 Index is at 649 and its futures contract size is 500 times the...
The case: Advanced Airport Passenger Processing System As the IT Manager, you were tasked to improve...
The case: Advanced Airport Passenger Processing System As the IT Manager, you were tasked to improve the performance of the local airport passenger processing system by addition new IT sections. The new airport will have less employees and faster passenger processing. This is to make the airport more efficient and more secure. The new system will replace the boarding-pass and ID Control personnel with IT System (consists of Hardware and software) . The passenger will walk through a passage surrounded...
how do you implement the strategy of having Compulsory Web based check-in due to the pandemic...
how do you implement the strategy of having Compulsory Web based check-in due to the pandemic in air asia.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT