Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


Object Oriented Programming (CS304)

Assignment No.2

 

Deadline

Your assignment must be uploaded before or on 29th November, 2012

 

Rules for Marking

It should be clear that your assignment will not get any credit if:

 

  • The assignment is submitted after due date.
  • Make sure your assignment solution is not copy pasted or modified from any source such as website, other students, groups, forums etc. Zero will be awarded straightaway and no further request will be entertained in this regard in any case. We may be lenient while giving attempts marks but no relaxation will be given for copied or modified assignments.
  • The assignment submitted in a format other than .cpp.

 

 

Objectives

The objectives of this assignment are, giving the idea of practical implementation of basic object oriented concepts like:

  • Composition
  • Aggregation

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Assignment:

You are required to provide a practical implementation in C++ for the following class diagram. You have to provide the solution in the form of classes in C++.

 

 

Class Diagram for Assignment No. 2

 

Figure 1: Object Model of Property Portal

 

 

Detail Description:

You are required to give C++ implementation of following classes:

 

  1. 1.      PropertyPortal
  2. 2.      PropertyType
  3. 3.      Commercial
  4. 4.      Residential

 

Following is the description of all data member and member functions of respective classes:

 

v     Data members for PropertyPortal:

 

  • NoOFUsers: This data member will be used to know the total number of users which visited this site/portal.
  • Name: Property portal will have some name; you can name it as VU-Real-Estate. 
  • UAN: Property portal will have some universal access number such as 111-111-111. 

 

v     Methods for PropertyPortal:

  • Constructor(s) and destructor.
  • Setter and getter function for NoOFUsers, Name, and UAN data members.
  • getPropertyInfo() will take information about property type, property belongs to which city and all other details which are available in PropertyType class.

 

v     Data members for PropertyType:

  • City: User will input city in which he/she want to search property details.

 

v     Methods for PropertyType:

  • Constructor(s) and destructor for class.
  • Setter and getter function for city data member.
  • getPropertyType() will ensure whether property is a commercial property or it is a residential property. A property can’t be both at same time.

 

v     Data members for Commercial

  • PropertyValue: Will show some fixed value for the commercial property.

 

v     Methods for Commercial

  • Constructor(s) and destructor for class.
  • Setter and getter function for PropertyValue data member.
  • getPlot() will return a plot number.

 

v     Data members for Residential

  • PropertyValue:  Will show some fixed value for the Residential property.

 

v     Methods for Residential

  • Constructor(s) and destructor for class.
  • Setter and getter function for propertyValue data member.
  • getPropertyCategory() This method will check for property category if it is a plot then it will return true else will print an appropriate message.  

 

Important Points:

 

  1. You also have to show the relationship (inheritance, association, aggregation, composition) between classes in proper C++ syntax with comments. No marks will be given for incorrect relationship.
  2. Dynamically allocate memory where required.
  3. Implement all member functions of each class. Make sure you use most appropriate return types and signatures for the function.  
  4. Implement constructors of all classes (Overload constructors if required also can use copy constructor if required).

 

 

Note: You are required to submit only .cpp file. Word document or any other file format will award you 0 marks straight away.

Views: 17933

Attachments:

Replies to This Discussion

class propertyportal; class propertytype; class commercial; class residential;

ab tu upload kr he den plz

Zero away hi away no chance ?????????now

Please check my code and comment please

#include<iostream.h>
#include <cstdlib>

/////// Commercial Class Starts/////
class commercial
{
private:
int property_val;
int plot_no;
public:
//Constructor & destructor
commercial();
~commercial();

//Set Function
int setproperty_val(int);
int setplot_no(int);
//Get funtion
int getproperty_val();
int get_plot();
};
//Constructor & Destructor
commercial::commercial()
{
property_val=0;
plot_no=0;
}
commercial::~commercial()
{
}

//Set Function
int commercial::setproperty_val(int val)
{
property_val=val;
}
int commercial::setplot_no(int val)
{
property_val=val;
}

//Set Function
int commercial::getproperty_val()
{
return property_val;
}
int commercial::get_plot()
{
return plot_no;
}
/////// Commercial Class Ends/////


/////// Residential Class Starts/////
class residential
{
private:
int property_val; //Property Value
commercial c;
public:
//Constructor & destructor
residential();
~residential();

//SET functions
int setproperty_val(int);

//GET functions
int getproperty_val();
int getproperty_category();
};

//Constructor & Destructor
residential::residential()
{
property_val=0;
}
residential::~residential()
{
}

//Set Functions
int residential::setproperty_val(int val)
{
property_val=val;
}


//Get Functions
int residential::getproperty_val()
{
return property_val;
}

//This method will check for property category if it is a plot then it will return true else will print an appropriate message.

int residential::getproperty_category()
{
if(c.get_plot() != 0)
{
return true;
}
else
{
cout"The property is commercial";
}
}
/////// Residential Class Ends/////


/////// Property type Class STARTS/////
class property_type
{
private:
char cityname[20]; //city Name
residential r; //Residential
public:
//Constructor & destructor
property_type();
~property_type();

//Set functions
char setcity(char a[]);

//Get functions
char* getcity();
void get_propertytype();
};

//Constructor & Destructor
property_type::property_type()
{
for(int i = 0; i < 15; i++)
{
cityname[i] = '\0';
}
}
property_type::~property_type()
{
delete[] cityname;
}

//Set Function
char property_type::setcity(char a[])
{
strcpy(cityname,a);
}

//Get Function
char* property_type::getcity()
{
return cityname;
}

//will ensure whether property is a commercial property or it is a residential property. A property can’t be both at same time.
void property_type::get_propertytype()
{
if(r.getproperty_category())
{
cout"//The property is commercial";
}
else
{
cout"The property is residential";
}
}
/////// Property type Class Ends/////

/////// Property Portal Class STARTS/////
class propertyportal
{
protected:
property_type* p;

private:
int no_of_user; //number of users visited
char name[20]; //Property portal name
char UAN[20]; //universal access number
public:
//Constructor & Destructor
propertyportal();
~propertyportal();

//Set Functions
int set_noofuser(int);
char set_name(char x[]);
char set_uan(char y[]);

//Get Functions
int get_noofuser();
char*get_name();
char* get_uan();

//get all property info
void get_propertyinfo(char* name,int num);


};

//Constructor & Destructor
propertyportal::propertyportal()
{
no_of_user=0;
for(int i = 0; i < 15; i++)
{
name[i] = '\0';
UAN[i] = '\0';
}
}
propertyportal::~propertyportal()
{
delete[] name;
delete[] UAN;
}

//Set Functions
int propertyportal::set_noofuser(int n)
{
no_of_user=n;
}
char propertyportal::set_name(char x[])
{
strcpy(name,x);
}
char propertyportal::set_uan(char y[])
{
strcpy(UAN,y);
}

//Get Functions
int propertyportal::get_noofuser()
{
return no_of_user;
}
char* propertyportal::get_name()
{
}
char* propertyportal::get_uan()
{
return UAN;
}

//will take information about property type, property belongs to which city and all other details which are available in PropertyType class.
void propertyportal::get_propertyinfo(char* name,int num)
{
p=new property_type(); //creating dynamic variable of class property_type
p->get_propertytype();
p->setcity(name);
cout"City name is"p->getcity();
}
/////// Property Portal Class Ends/////

main()
{
system("pause");
return EXIT_SUCCESS;
}

Please check my code 

# include<iostream.h>
# include<conio.h>
class Date{

private:
int PropertyPortal, PropertyType, Commercial, Residentia;
static NoOfUsers, UAN, Name;
public:
void setUAN(int aUAN);
void setNoOfUsers(int aNoOfUsers);
int getName() const;
void addName(int x);
void setUAN(int aUAN);
int getUAN() const;
void addUAN(int x);
void setNoOfUsers(int aNoOfUsers);
int getNoOfUsers() const;
void addNoOfUsers(int x);
bool leapNoOfUsers(int x)const;
Date(int aName , int aUAN, int aNoOfUsers);
void setUAN(int aName , int aUAN, int aNoOfUsers);
~UAN(); //Destructor
};

UAN UAN::defaultUAN(111,111,111);

UAN::UAN(int aName, int aUAN, int aNoOfUsers)
{
if(aName==0)
{
this->Name = defaultUAN.Name;
}
else
{
setName(aName);
}

if(aUAN==0)
{
this->UAN = defaultUAN.UAN;
}
else
{
setUAN(aUAN);
}

if(aNoOfUsers==0)
{
this->NoOfUsers = defaultUAN.NoOfUsers;
}
else
{
setNoOfUsers(aNoOfUsers);
}

}

void UAN::setUAN(int a) {
if(a > 0 && a <= 12)
{
UAN = a;
}
}

int UAN:: getUAN() const {
return UAN;
}

void UAN::addNoOfUsers(int x)
{
NoOfUsers += x;
if(Name == 29 && UAN == 2 && !leapNoOfUsers(NoOfUsers))
{
Name = 1;
UAN = 3;
}
}

bool UAN::leapNoOfUsers(int x) const {
if((x%4 == 0 && x%100 != 0) || (x%400==0))
{
return true;
}
return false;
}

void UAN::setNoOfUsers(int aNoOfUsers){
NoOfUsers=aNoOfUsers;
}
void UAN::setName(int aName){
Name=aName;

}

void UAN::setUAN(int aName , int aUAN, int aNoOfUsers){
setName(aName);
setUAN(aUAN);
setNoOfUsers(aNoOfUsers);
coutName"/"UAN"/"NoOfUsersendl;

}


Date::~UAN(){
cout"Total Number of Prototypes"endl;
}
int main()
{
UAN aUAN(0,0,0);

aUAN.setUAN(111,111,111);
system("pause");
}

yar errors bhot ziada hain

thnxxxxxxxxxxxxxxx a lot bhai jeeeeeeeeeeeee

RSS

Looking For Something? Search Below

VIP Member Badge & Others

How to Get This Badge at Your Profile DP

------------------------------------

Management: Admins ::: Moderators

Other Awards Badges List Moderators Group

Latest Activity

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service