CS304 Assignment No 02 Spring 2017 | Virtual Study Solutions

Adsetra Ads

 

CS304 Assignment No 02

Here is the complete assignment and Solution of CS304 Assignment No 02 Spring 2017. Please discuss the ideas with fellow students about problem. CS304 Assignment Object Oriented Programming Deadline: May 19, 2017.Previously we shared : CS304 assignment No 01 Spring 2017 Solution and Discussion.
CS304 Assignment No 02 Spring 2017
CS304 Assignment No 02 Spring 2017


Lectures Covered in CS304 Assignment :

This assignment covers Lecture No 7 to 15.

CS304 Assignment Deadline:

Your assignment must be uploaded/submitted at or before May 19, 2017.
For any query about the assignment, contact at CS304@vu.edu.pk
You Can Also Download CS304 Solved Mid Papers, CS304 Short Notes, CS304 Assignment Solutions, CS304 Lecture Wise Questions Answers Files, CS304 Solved MCQs, CS304 Solved Quiz , CS304 Solved Mid Term Subjective Papers , CS304 Mid Term Objective Papers from Virtual Study Solutions For Preparation of Mid Term Papers.

Recommended : CS403 Assignment No 2 Spring 2017 Solution and Discussion

CS304 Assignment No 02 Problem Statement:

In continuation of Assignment No. 1, we have the following part of class diagram showing composition relationship:

You are required to implement above class diagram (complete program) in C++ with all data members, constructors, member functions and concept (composition) given in the class diagram.
Write your code to perform the following operations in main().

See the sample output to view the messages you need to print in constructors of all classes.

CS304 Assignment Question
CS304 Assignment Question

Please Note: Use member initialization list to initialize the composed objects.
Sample Output:

CS304 Assignment Question output
CS304 Assignment Question output

CS304 ASSIGNMENT NO 02 SOLUTION:

You can download CS304 Assignment Solution file from the link below:

cs304_assignment_no_2_solution_2017.pdf

Solution Idea:

#include<iostream>
using namespace std;
class pully
{
private:
int noofteeths;
public:
pully(int n)
{
noofteeths=n;
cout<<"\n\nPully constructor called!";
}
void show()
{
cout<<"\n\nThe no of teeths of pully are : "<<noofteeths;
}
};
class GearBox
{
private:
string transmission;
pully P1;
public:
GearBox (string t, const pully p)
:transmission(t), P1(p)
{
cout<<"\n\nGearBox constructor called!";
}
void show()
{
cout<<"\n\nTransmission of vehicle : "<< transmission;
P1.show();
}
};
class Vehicle
{
private:
string model;
string color;
GearBox g1;
public:
Vehicle (string m, string c, const GearBox g)
: model (m),color(c), g1(g)
{
cout<<"\n\nVehicle constructor called!";
}
void show()
{
cout<<"\n\nModelof vehicle : "<<model;
cout<<"\n\nColor of vehicle : "<<color;
g1.show();
}
};
main()
{
pully p(20);
GearBox g("Manual", p);
Vehicle V("Honda Toyota", "Black", g);
V.show();
cout<<"\n\n";

}

If You liked This Post Please share with Your friends. Thank You.

Post a Comment

 

Top