Question

PLEASE HELP ASAPObject Relationship In Module 6 Object Relationship, we have learned to construct relationships between objects use proper C+

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

#include <iostream>
#include <string>
#include <vector>
using namespace std;

class Passenger
{
   string name;
public:
   Passenger(string n) : name(n) {}
   string getName() { return name; }
};

class Car
{
   Engine model;
   vector<Passenger> passengers;
public:
   Car(Engine engine, vector<Passenger> pass) : Engine(engine), passengers(pass) {}
   bool addPassenger(name);
};

* Relationship between the class Car and Passenger is an aggregation, means, a Car may or may not have passengers(s) in it. So, a vector of type Passenger
is used to depict this relationship. Passengers may come or go can be implemented by adding or removing Passengers from the vector.

** bool addPassenger(name) --> This method adds a Passenger to the passenger list (here, vector). It takes the name of the passenger as input, creates an instance of a Passenger and adds it to the list and returns TRUE/FALSE whether the insertion operation is a success.

Add a comment
Know the answer?
Add Answer to:
PLEASE HELP ASAP Object Relationship In Module 6 Object Relationship, we have learned to construct relationships between...
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
  • Please do Realization, Directed Association, Reflexive Association, and Multiplicity........ To define 4 different object relationships with...

    Please do Realization, Directed Association, Reflexive Association, and Multiplicity........ To define 4 different object relationships with proper syntax with no compilation error. Select 4 different types of object relationship out of 8 listed (in the picture below) For each of the 4 relationships you may create any tow objects and these classes can be use for different relationships. The class of objects can be reused in other relationship. That brings the max count, not min, of classes required is eight...

  • Please do this in C++. Thank you in advance. Note that you have to carefully create...

    Please do this in C++. Thank you in advance. Note that you have to carefully create your class using the names and capitalization shown below. Put comments into your program, make sure you indent your program properly, and use good naming conventions. Create a class called entry. It should have two private data members of type std::string. One represents a name and the other represents an email address. Make sure you give them ,meaningful names. Create public getters and setters...

  • 1) Introduction to Objects (with Constructors and Properties) We need to answer the question which are...

    1) Introduction to Objects (with Constructors and Properties) We need to answer the question which are below. and instruction are given down starting with part(b). Just we need to copy paste code file and follow the instruction and answer related to them. a) Enter the following program.Answer The questions below the codes, Notice that it consists of two classes that will go into the same project. Please put each class into its own code file (use Lab5_1 for the Project...

  • please need help with the java program A micro car rental company. package yourLastName.cis4110.assignment5; Please create...

    please need help with the java program A micro car rental company. package yourLastName.cis4110.assignment5; Please create an enum type, say Cartype, featuring all rental car types -- SUBCOMPACT, COMPACT, MIDSIZE, FULLSIZE (You may put the enum definition in Car class) class Car Instance variables: - private String plateNum - private Cartype carType - private boolean availability Member methods:             - Please define all setters and getters class RentACar - This is a five car system for prototyping instance variables:...

  • please help Write a simple program with Student class having STL list of Record's structure as...

    please help Write a simple program with Student class having STL list of Record's structure as a member. 1. Records of the Students are not accessible to the outside world. 2. Student shall output its standing (Freshman, Sophomore etc). 3. A Student can only be created with the name 4. A class can only be added if there is a class name and the passing grade. Driver program creates a Student, adds few classes to the Student's records, then prints...

  • Must be in Java. Please show step by step process with proper explanation and comments. Please...

    Must be in Java. Please show step by step process with proper explanation and comments. Please maintain proper indentation. CODE PROVIDED: Doctor.java HospitalDoctor.java Q1Runner.java import java.util.Scanner; public class Q1Runner { public static void main(String[] args) { Scanner kb = new Scanner(System.in);               // Do your work here        } } You are asked to create the starting point of a system to represent several types of medical doctors. You decided to implement two classes: a superclass...

  • NEED ASAP PLEASE WILL GIVE GOOD RATE RIGHT AWAY FOR ALL ANSWERS! JAVA C) Write a...

    NEED ASAP PLEASE WILL GIVE GOOD RATE RIGHT AWAY FOR ALL ANSWERS! JAVA C) Write a code to define/ derive a new subclass named superVillan. The SuperVillan object has an objective (like world domination- string) and a nemesis (SuperHero) Add these attributes to the sub class. write proper cinstructor I: Programming rhe following code segment w segment will be used in the epresents a superhero be used in the next two ques blic class Superhero ( private final string private...

  • *** FOR A BEGINNER LEVEL JAVA CLASS, PLEASE KEEP CODE SIMPLE, AND WE USE BLUE J...

    *** FOR A BEGINNER LEVEL JAVA CLASS, PLEASE KEEP CODE SIMPLE, AND WE USE BLUE J IN CLASS (IF IT DOESNT MATTER PLEASE COMMENT TELLING WHICH PROGRAM YOU USED TO WRITE THE CODE, PREFERRED IS BLUE J!!)*** ArrayList of Objects and Input File Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an ArrayList<Car> list . Program should work for input file containing info...

  • Need help doing program In bold is problem E2 #include<iostream> #include<string> #include<vector> using namespace std; //Car...

    Need help doing program In bold is problem E2 #include<iostream> #include<string> #include<vector> using namespace std; //Car class //Defined enum here enum Kind{business,maintenance,other,box,tank,flat,otherFreight,chair,seater,otherPassenger}; //Defined array of strings string KIND_ARRAY[]={"business","maintenance","other,box","tank,flat","otherFreight","chair","seater","otherPassenger"}; class Car { private: string reportingMark; int carNumber; Kind kind; //changed to Kind bool loaded; string destination; public: //Defined setKind function Kind setKind(string knd) { for(int i=0;i<8;i++) //repeat upto 8 kinds { if(knd.compare(KIND_ARRAY[i])==0) //if matched in Array kind=(Kind)i; //setup that kind } return kind; } //Default constructor Car() { } //Parameterized constructor...

  • Need help with this class and function please!!! #include <iostream> using namespace std; c...

    Need help with this class and function please!!! #include <iostream> using namespace std; class Team { string teamId; string name; string coach; Team *next; friend class teamlist; public: Team * getNext(); return next; void setNext(Team *r); next=r;    string getTeamId(); return teamId;    void setTeamId(string aTeamId); teamId = aTeamId;    string getName(); return name;    void setName(string aName); name = aName;    string getCoach(); return coach; void setCoach(string aCoach); coach = aCoach; } team list The team list is a dynamic linked list of team...

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