C++ Programming Language Computers have the following characteristics: * an opsy
ID: 3626410 • Letter: C
Question
C++ Programming LanguageComputers have the following characteristics:
* an opsys (operating system - you can store this as a string)
* memory (you can store this as an integer)
Your class should have two constructors:
* the default constructor should initialize the opsys and memory of a Computer to “Unknown” or zero respectively
* a second constructor should take a string and an integer (an operating system name and amount of memory) as parameters and initialize the Computer's opsys and memory to the values in those parameters.
Your class should have:
* accessor and mutator methods for the Computer’s memory and
* only an accessor method for the operating system.
1.) Write your class declaration below. It should be in a file named Computer.h
Be sure to add any code necessary to make your Computer class work in future programs.
2.) Write your class implementation below. It should be in a file named Computer.cpp
Be sure to add any code necessary to make your Computer class work in future programs.
Explanation / Answer
Computer.h #ifndef COMPUTER_H #define COMPUTER_H class Computer { private: string opsys; int memory; public: Computer(void) { opsys = "Unknown"; memory = 0; } Computer (string name, int size) { opsys = name; memory = size; } string getOpsys() return opsys; int getMemory() return memory; int setMemory (int size) { memory = size; return memory; } }; #endif Computer.cpp #include "Computer.h" int main () { const Computer comp1; const Computer comp2 ("Windows", 4); int mem = comp2.getMemory(); //etc return 0; } You can add stuff to the main method as necessary. Hope it helps, and please rate lifesaver!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.