Skip to content

304 - Object Oriented Programming

8 Topics 27 Posts
  • 0 Votes
    7 Posts
    580 Views
    cyberianC

  • 0 Votes
    3 Posts
    140 Views
    zaasmiZ
    #include<iostream> using namespace std; class Question { private : int QuestionID; string QuestionType; int QuestionMarks; public : Question() { cout<<"Enter Question ID : "; cin>>QuestionID; cout<<"Enter Question Type : "; cin>>QuestionType; cout<<"Enter Question Marks : "; cin>>QuestionMarks; } void setQueID(int id) { QuestionID=id; } void setQueType(string type) { QuestionType=type; } void setQueMarks(int marks) { QuestionMarks=marks; } int getQueID() const { return QuestionID; } string getQueType() const { return QuestionType; } int getQueMarks() const { return QuestionMarks; } }; class Exam { private : string ExamType; string CourseCode; static const int NoOfQuestions=2; Question *questions[NoOfQuestions]; public : Exam(string EType, string CCode) { ExamType=EType; CourseCode=CCode; for(int i=0; i<NoOfQuestions; i++) { cout<<"\n***** Enter Data of Question No. "<<i+1<<" *****\n"; questions[i] = new Question(); } } void DisplayInfo() { cout<<"----------------------------\n"; cout<<"**** Displaying Exam Information ****"; cout<<"\n----------------------------"; cout<<"\nExam Type : "<<ExamType; cout<<"\nCourse Code : "<<CourseCode; cout<<"\nTotal No of Questions for Exam : "<<NoOfQuestions; cout<<"\n----------------------------\n"; cout<<"**** Displaying Question Information ****"; cout<<"\n----------------------------"; for(int i=0; i<NoOfQuestions; i++) { cout<<"\nQuestion No. : "<<i+1; cout<<"\nQuestion Id : "<<questions[i]->getQueID(); cout<<"\nQuestion Type : "<<questions[i]->getQueType(); cout<<"\nQuestion Marks : "<<questions[i]->getQueMarks(); cout<<"\n----------------------------"; } } }; main() { cout<<"\n\t\tCS304 Assignment No. 2 Solution \n"; cout<<"\nPlease Subscribe Cyberian Youtube Channel to get Solutions of all Programming Assignments\n\n"; string type, code; cout<<"Enter Exam Type : "; getline(cin, type); cout<<"Enter Course Code : "; getline(cin, code); Exam exm1(type,code); exm1.DisplayInfo(); }
  • 0 Votes
    2 Posts
    3k Views
    cyberianC

    a9712a5a-d798-4d9b-9407-b5881a69db28-image.png

  • CS304 Handouts pdf

    1
    0 Votes
    1 Posts
    151 Views
    No one has replied
  • 0 Votes
    4 Posts
    764 Views
    zareenZ

    Solution:
    f2d0591f-9ed5-4a39-bd65-d4d6febe10ad-image.png

  • 0 Votes
    4 Posts
    452 Views
    zareenZ

    Compile Online C++ Code

  • 0 Votes
    5 Posts
    296 Views
    zareenZ

    Solution:

    #include <iostream> using namespace std; class Franchise{ string name; string city; public: Franchise(){ name= ""; city=""; } void setname(string n){ name= n; } void setcity(string c){ city=c; } string getfname(){ return name; } string getfcity(){ return city; } }; class League{ private: string name; string year; string country; Franchise franchiseObject; public: League(string fname,string fcity,string n,string y,string c){ franchiseObject.setname(fname); franchiseObject.setcity(fcity); name=n; year=y; country=c; } void displayInfo(){ cout << "League name : " << name<<endl; cout << "League year : " << year<<endl; cout << "League country : " << country<<endl; cout << "Franchise name : " << franchiseObject.getfname()<<endl; cout << "Franchise city : " << franchiseObject.getfcity()<<endl; } }; int main() { League lg("Islamabad United","Islamabad","PSL","2020","PAKISTAN"); lg.displayInfo(); return 0; }
  • 0 Votes
    1 Posts
    169 Views
    No one has replied