April 7, 2025 10:25:57 PM Menu

cs201 Assignment No.3

Simply copy this code and paste in Dev C++. Save it by your id and submit it.😄

cs201 Assignment No.3\
#include <iostream>
#include <string>


using namespace std;
class Laptop
{
    private:
        string Brand, Processor;
        int Ram, hardDrive;
 
    public:
    Laptop()
        {
            cout<<"Default Constructor Called... \n";
            Brand = "None";
            Processor = "None";
            Ram = 0;
            hardDrive = 0;
        }
 
        void setBrand(string b)
        { Brand = b; }
        void setProcessor(string p)
        { Processor = p; }
        void setRam(int r)
        { Ram = r; }
        void sethD(int hd)
        { hardDrive = hd; }
 
        string getBrand()
        { return Brand; }
        string getProcessor()
        { return Processor; }
        int getRam()
        { return Ram; }
        int getHD()
        { return hardDrive; }
 
    Laptop(string theBrand, string theProcessor, int theRam, int thehardDrive)
        {
          cout<<"Parameterized Constructor Called...\n";
          Brand = theBrand;
          Processor = theProcessor;
          Ram =  theRam;
          hardDrive = thehardDrive;
        }
    };
int main()
{

  Laptop l;
  cout<<"\nBrand : "<<l.getBrand()<<"\nProcessor : "<<l.getProcessor()<<"\nRam : "<<l.getRam()<<"\nHard Drive : "<<l.getHD()<<"\n\n";

  Laptop l2("dell", "i5", 4, 500);
  cout<<"\nBrand : "<<l2.getBrand()<<"\nProcessor : "<<l2.getProcessor()<<"\nRam : "<<l2.getRam()<<"\nHard Drive : "<<l2.getHD()<<"\n";
  system("pause");
}




Don't forget to Bookmark our page. Thanks for Visiting
21 Jul 2018

Post a Comment Blogger

Warmly Thanks for commenting. We will reply you soon

Emoticon
:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Top