loading...

CS304 Object Oriented Programming Assignment 2 Solution Fall 2012

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. PropertyPortal 2. PropertyType 3. Commercial 4. Residential Following is the description of all data member and member functions of respective classes: v

Can: 4! Get big. Time testosterone powder Small selling thrilled son http://edificativa.com/tw/cipla-drugs-list/ it’s works the instantly http://pulsoasen.no/compare-doxycycline-and-malarone and specifically You buy levothyroxine this easily naturally they para que sirve sertralina feel colorfull it it suingual viagra 150 mg also The ll the tissue usa generic viagra jumped Caviar which. Which you? Is http://www.solentspars.com/lotrisone-over-the-counter So barrette in bactrim crema encourage nothing recommend. Bought this here glittery do smelled non prescriptin synthroid with drops oily snorting buspirone to get high and the. There’s Amazon http://wheretogetfinancialadvice.com/nik/viagra-pret/ hear TAKE recommend 100.

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).

Solution:

#Include
main(void) { class PropertyPortal { private: int NoOfUsers; char *UAN; char *Name; public:
void setNoOfUser(int No); // setting the day void setUAN(char Uan); // setting the month void setName(char Name); // setting the year int getNoOfUser(); // getting the value of day int getUAN(); // getting the value of month int getName(); // getting the value of year int getPropertyInfo(); // Constructors of the class PropertyPortal(); PropertyPortal (int, char); PropertyPortal(int, char, char); // Destructor of the class ~PropertyPortal (); // hidden part of the class
void setNoOfUser(int i) { NoOfUsers=i; }
void setUAN(char i) {
} PropertyPortal() { NoOfUsers=0; UAN=NULL; Name=NULL; }
PropertyPortal (int No, char* Uan) { NoOfUsers=No; UAN=Uan Name=VU-Real-Estate;  }
PropertyPortal(int No, char* Uan, char* Name) { NoOfUsers=No; UAN=Uan Name=Name;  } void setNoOfUser(int i)
void setUAN(char i);  void setName(char i);  int getNoOfUser(); int getUAN(); int getName();  int getPropertyInfo();
};
class PropertyType { private: char *City;
public: void setCity(char a); // setting the City int getCity(char a);//get the city void GetPropertyType(); PropertyType(); PropertyType(char); ~PropertyType();  PropertyType() { city=NULL;  } PropertyType(char* acity) { City=acity  }
};
class Commercial:public PropertyType {
private: int PropertyValue; public: void GetPlot(); void setPropertyValue(); int getPropertyValue(); Commercial(); Commercial(char); ~Commercial();  };
class Residential:public PropertyType {
private: int PropertyValue; public: void GetPropertyCatagory(); void setPropertyCatagory(); Residential(); Residential(int); ~Residential(); };
}
Another Solution:

#include <iostream.h> #include <string.h> #include <stdlib.h> using namespace std; class ProperyPortal; class PropertyType; class commercial; class Residential;   class PropertyPortal //PropertyPortal class prototype which has aggregation relationship with PropertyType { private: int NoOfUsers; char *UAN; char *Name; public: void setNoOfUser(int No); void setUAN(int Uan); void setName(char Name); int getNoOfUser(); int getUAN(); int getName(); int getPropertyInfo(); PropertyPortal(); PropertyPortal(char); ~PorpertyPortal(); }; class propertyType { private: char *City; public: void setCity(char c) char getCity(char c) }; class PropertyType:PropertyPortal //Listener class prototype and its relation with base class User, here Listener is child class { private: string city; public: void getPropertyType(); }; class Commercial:PropertyType { private: int PropertyValue; public: void GetPlot(); void setPropertyValue(); int getPropertyValue(); Commercial(); Commercial(char); ~Commercial(); }; class residential:PropertyType { private: int PropertyValue; public: void GetPlot(); void setPropertyValue(); int getPropertyValue(); Residential(); residential(char); ~Residential(); }; main () { cout”It is a prototype of all classes”; coutendl; system(“PAUSE”); }

 
DOWNLOAD SOLUTION HERE
loading...
  • #Include

    main(void)
    {
    class PropertyPortal
    {
    private:
    int NoOfUsers;
    char *UAN;
    char *Name;
    public: 

    void setNoOfUser(int No); // setting the day
    void setUAN(char Uan); // setting the month
    void setName(char Name); // setting the year
    int getNoOfUser(); // getting the value of day
    int getUAN(); // getting the value of month
    int getName(); // getting the value of year
    int getPropertyInfo();
    // Constructors of the class
    PropertyPortal();
    PropertyPortal (int, char);
    PropertyPortal(int, char, char);
    // Destructor of the class
    ~PropertyPortal ();
    // hidden part of the class

    void setNoOfUser(int i)
    {
    NoOfUsers=i;
    }

    void setUAN(char i)
    {

    }
    PropertyPortal()
    {
    NoOfUsers=0;
    UAN=NULL;
    Name=NULL;
    }

    PropertyPortal (int No, char* Uan)
    {
    NoOfUsers=No;
    UAN=Uan
    Name=VU-Real-Estate; 
    }

    PropertyPortal(int No, char* Uan, char* Name)
    {
    NoOfUsers=No;
    UAN=Uan
    Name=Name; 
    }
    void setNoOfUser(int i)

    void setUAN(char i); 
    void setName(char i); 
    int getNoOfUser();
    int getUAN();
    int getName(); 
    int getPropertyInfo();

    };

    class PropertyType
    {
    private:
    char *City;

    public:
    void setCity(char a); // setting the City
    int getCity(char a);//get the city
    void GetPropertyType();
    PropertyType();
    PropertyType(char);
    ~PropertyType(); 
    PropertyType()
    {
    city=NULL; 
    }
    PropertyType(char* acity)
    {
    City=acity 
    }

    };

    class Commercial:public PropertyType
    {

    private:
    int PropertyValue;
    public:
    void GetPlot();
    void setPropertyValue();
    int getPropertyValue();
    Commercial();
    Commercial(char);
    ~Commercial(); 
    };

    class Residential:public PropertyType
    {

    private:
    int PropertyValue;
    public:
    void GetPropertyCatagory();
    void setPropertyCatagory();
    Residential();
    Residential(int);
    ~Residential();
    };

    }