CS304 Assignment 2 Solution and Discussion


  • Cyberian's Gold

    Assignment No. 02
    Semester: Fall 2019
    CS304- Object Oriented Programming

    Total Marks: 20

    Due Date: 28/11/2019

    Uploading instructions:

    • Your assignment should be in .CPP format (Any other formats like scan images, PDF, zip, doc, rar and bmp etc. will not be accepted).
    • Save your assignment with your ID (e.g. bc000000000.CPP).
    • No assignment will be accepted through email.

    Rules for Marking:

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

    • The assignment is submitted after due date.
    • The submitted assignment does not open, execute or file is corrupted.
    • Your assignment is copied from internet, handouts or from any other student.
    (Strict disciplinary action will be taken in this case).

    Lectures Covered:

    This assignment covers Lecture # 7-15.

    Assignment
    Consider the following part of class diagram which is showing composition relationship between League and Franchise classes.
    9795b0c6-5a4d-4994-85bf-9928a2f4f01b-image.png

    Tasks to do:

    You are required to write C++ code to create Franchise and League classes. Your classes should contain data members, constructors and member functions according to the given diagram. You also need to implement composition relationship between these classes.

    Your output should be same as sample output.

    Sample Output:
    1ad0921d-927b-4488-95bb-e95b87618a61-image.png

    Best of luck!

    NOTE: Do not put any query on MDB about this assignment, if you have any query then email at [email protected]. Furthermore, if any student found cheating from any other student or from online forums then he/she will be awarded ZERO right away and strict disciplinary action will be taken against the student.

    Deadline: Your assignment must be uploaded/submitted on or before 28th November 2019.


  • Cyberian's Gold

    
    
        #include<iostream>
        #include<string>
        using namespace std;
    
        class Franchise{
        private:
        string name;
        string city;
    
        public:
        Franchise();
        void setName(string);
        void setCity(string);
        string getName();
        string getCity();
        };
    
        Franchise::Franchise(){
    
        }
        void Franchise::setName(string n){
        name = n;
        }
    
        void Franchise::setCity(string c){
        city = c;
        }
        string Franchise::getName(){
        return name;
        }
    
        string Franchise::getCity(){
        return city;
        }
    
        class league{
        private:
        string naame;
        string country;
        int year;
        Franchise french;
    
        public:
        league(string , int, string , string , string);
        void displayInfo();
        };
    
        league::league(string n, int y, string c, string name, string city){
        naame = n;
        country = c;
        french.setCity(city);
        city = french.getCity();
        year = y;
        french.setName(name);
        name = french.getName();
        }
    
        void league::displayInfo(){
        cout"League Name:"naameendl;
        cout"League Year:"yearendl;
        cout"League County :"countryendl;
        cout"Franchise name:"french.getName()endl;
        cout"Frenchise City:"french.getCity()endl;
        }
    
        int main(){
    
        league l("PSL",2020,"Pakistan","Sargodha Eagles","Sargodha");
        l.displayInfo();
    
        }
    
    

  • Cyberian's Gold


  • Cyberian's Gold

    
    
        #include<iostream>
        #include<string>
        using namespace std;
    
        class Franchise{
        private:
        string name;
        string city;
    
        public:
        Franchise();
        void setName(string);
        void setCity(string);
        string getName();
        string getCity();
        };
    
        Franchise::Franchise(){
    
        }
        void Franchise::setName(string n){
        name = n;
        }
    
        void Franchise::setCity(string c){
        city = c;
        }
        string Franchise::getName(){
        return name;
        }
    
        string Franchise::getCity(){
        return city;
        }
    
        class league{
        private:
        string naame;
        string country;
        int year;
        Franchise french;
    
        public:
        league(string , int, string , string , string);
        void displayInfo();
        };
    
        league::league(string n, int y, string c, string name, string city){
        naame = n;
        country = c;
        french.setCity(city);
        city = french.getCity();
        year = y;
        french.setName(name);
        name = french.getName();
        }
    
        void league::displayInfo(){
        cout"League Name :"naameendl;
        cout"League Year :"yearendl;
        cout"League County :"countryendl;
        cout"Franchise name :"french.getName()endl;
        cout"Frenchise City :"french.getCity()endl;
        }
    
    

  • Cyberian's Gold



    Recent Topics


|