Question

C++ Design: Create a UML Class diagram that reflects the software design of your entire program...

C++

Design: Create a UML Class diagram that reflects the software design of your entire program

Q3. Create a class called Passenger that represents passengers of an airline company. A passenger is defined by the following information:
- Passenger ID (int)
- Name (string)
- Address (string)
- Tel (string)
- Date of birth (of type Date from Q2)
Provide the following functions:
- A constructor that initializes the data members and provides default arguments.
- Accessor methods that return the value of the data members.
- Functions that change the address, tel., and date of birth of a passenger.
- A function that prints information about a passenger.
Test your class by dynamically creating two Passenger objects and calling on them the above functions.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Passeneger

-id : int

-name : string

-address : string

-telephone number : string

-date of birth: Date

+Passenger()

+getId() : int

+getName() : string

+getAddress() : string

+getTel(): string

+getDOB() : Date

+setId() : void

+setName(): void

+setAddress():void

+setTel() : void

+setDOB(): void

+print() : void

#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
class Date
{
public:
int day;
int month;
int year;
};
class Passenger
{
private:
int id;
string name;
string address;
string tel;
Date date;
public:
Passenger()
{
id=100;
name = "Robert";
address="4th Lane Church Street New York";
tel="+045 2443551";
date.day=1;
date.month=1;
date.year=1997;
}
int getId()
{
return id;
}
string getName()
{
return name;
}
string getAddress()
{
return address;
}
string getTel()
{
return tel;
}
string getDOB()
{
string s = std::to_string(date.day)+"/"+std::to_string(date.month)+"/"+std::to_string(date.year);
return s;
}
void setId(int i)
{
id= i;
}
void setName(string n)
{
name= n;
}
void setAddress(string a)
{
address=a;
}
void setTel(string t)
{
tel=t;
}
void setDOB(Date d)
{
date = d;
}
void print()
{
cout<<"Passenger Information:\nId: "<<id<<endl;
cout<<"Name: "<<name<<endl;
cout<<"Address: "<<address<<endl;
cout<<"Telephone: "<<tel<<endl;
cout<<"Date of Birth: "<<getDOB()<<endl;
}
};
  
int main()
{
Passenger p1;
Date d1;
d1.day=11;
d1.month=11;
d1.year=1780;
p1.print();
Passenger p2;
p2.setId(101);
p2.setName("Einstein");
p2.setAddress("5th Cross, New Jersey USA");
p2.setTel("+045 123456");
p2.setDOB(d1);
p2.print();
return 0;
}

Add a comment
Know the answer?
Add Answer to:
C++ Design: Create a UML Class diagram that reflects the software design of your entire program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create the class Book which has the following members: 1. private members: 1. title as String...

    Create the class Book which has the following members: 1. private members: 1. title as String 2. isbn as String 3. author as String 4. price as double 2. public members: 1. default constructor which initializes all data members to their default values. 2. non-default constructor which initializes all data members to parameters values. 3. toString which returns a representing String of the Book. 4. add all the setters and getters. Create the class EBook which is a subclass of...

  • Create the program in C++ please. The new operator as outlined in 10.9 . Create a...

    Create the program in C++ please. The new operator as outlined in 10.9 . Create a Test class that includes the following Data members • First Name, last name, test1, test2, test3 o Methods • Accessor methods for each of the data members' • Mutator methods for each of the data members . A Default Constructor . A constructor that will accept arguments for each of the 5 data members • A method that will calculate the average of the...

  • Create a UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two constructors:...

  • Design a class named Person with fields for holding a person's name, address, and telephone number...

    Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes...

  • Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and...

    Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and a driver program called invoiceDriver.cpp. The class Invoice is used in a hardware store to represent an invoice for an item sold at the store. An invoice class should include the following: A part number of type string A part description of type string A quantity of the item being purchased of type int A price per item of type int A class constructor...

  • 1) This exercise is about Inheritance (IS-A) Relationship. A) First, draw the UML diagram for class...

    1) This exercise is about Inheritance (IS-A) Relationship. A) First, draw the UML diagram for class Student and class ComputerSystemsStudent which are described below. Make sure to show all the members (member variables and member functions) of the classes on your UML diagram. Save your UML diagram and also export it as a PNG. B) Second, write a program that contains the following parts. Write each class interface and implementation, in a different .h and .cpp file, respectively. a) Create...

  • 1. Please write the following program in Python 3. Also, please create a UML and write...

    1. Please write the following program in Python 3. Also, please create a UML and write the test program. Please show all outputs. (The Fan class) Design a class named Fan to represent a fan. The class contains: Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. A private int data field named speed that specifies the speed of the fan. A private bool data field named on that specifies...

  • Please write the program in C++ Problem Description: Design a class called Date. The class should...

    Please write the program in C++ Problem Description: Design a class called Date. The class should store a date in three integers: month, day, and year.     Create the necessary set and get methods.       Design member functions to return the date as a string in the following formats:                                     12/25/2012                                     December 25, 2012                                     25 December 2012 Input Validation: Do not accept values for day greater than 30 or less than 1. Do not accept values for month...

  • Create a UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? 3. Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two...

  • Overloading Design a UML diagram for a TimeClock class with the following private data members: •...

    Overloading Design a UML diagram for a TimeClock class with the following private data members: • float days • float hours The class should also have the following public member methods: • Constructor with a default that sets the data values to 0 • getDays to return the private data member days • getHours to return the private data member hours • setDays to set the private data member days • setHours to set the private data member hours •...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT