Question

Some code in c ++ and its UML to apply inheritance and get and set methods,...

Some code in c ++ and its UML to apply inheritance and get and set methods, the code must be about computers, also applying object-oriented programming

I need a code in C++ applying OOP with the topic of computers, then in the code must include the get method returns the variable value, and the set method sets the value.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the code I have written to solve your question using OOPS concepts.

CODE:

########################################################

#include<iostream>
using namespace std;

class Computer
{
int ram;
string os;
int bit;
public:
void setRam(int ram) {
this->ram=ram;
}
void setOs(string os) {
this->os = os;
}
void setBit(int bit) {
this->bit = bit;
}
int getRam() {
return this->ram;
}
string getOs() {
return this->os;
}
int getBit() {
return this->bit;
}
};

class Gaming : public Computer
{
int graphicCardSize;
bool gpu;
string gpuType;
public:
void setGraphicCardSize(int graphicCardSize) {
this->graphicCardSize = graphicCardSize;
}
void setGpu(bool gpu) {
this->gpu = gpu;
}
void setGpuType(string gpuType) {
this->gpuType = gpuType;
}
int getGraphicCardSize() {
return this->graphicCardSize;
}
int getGpu() {
return this->gpu;
}
string getGpuType() {
return this->gpuType;
}

};

int main()
{
Gaming g;
g.setBit(64);
g.setGpu(1);
g.setGpuType("GTX RX1000");
g.setGraphicCardSize(16);
g.setOs("Windows");
g.setRam(64);

//printing output
cout<<"Ram size: "<<g.getRam();
cout<<"\nIs GPU present: "<<g.getGpu();
cout<<"\nGPU type: "<<g.getGpuType();
cout<<"\nOperating System: "<<g.getOs();
}

##########################################################

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Some code in c ++ and its UML to apply inheritance and get and set methods,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Some code in c ++ and its UML to apply inheritance and get and set methods, the code must be about computers, also applying object-oriented programming I need a code in C++ applying OOP with the top...

    Some code in c ++ and its UML to apply inheritance and get and set methods, the code must be about computers, also applying object-oriented programming I need a code in C++ applying OOP with the topic of computers, then in the code must include the get method returns the variable value, and the set method sets the value.

  • In c# So far, you have created object-oriented code for individual classes. You have built objects...

    In c# So far, you have created object-oriented code for individual classes. You have built objects from these classes. Last week, you created a UML for new inherited classes and objects. Finally, you have used polymorphism. When you add abstraction to this mix, you have the “4 Pillars of OOP.” Now, you begin putting the pieces together to create larger object-oriented programs. Objectives for the project are: Create OO classes that contain inherited and polymorphic members Create abstracted classes and...

  • Create a UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two constructors:...

  • 1) This exercise is about Inheritance (IS-A) Relationship. A) First, draw the UML diagram for class...

    1) This exercise is about Inheritance (IS-A) Relationship. A) First, draw the UML diagram for class Student and class ComputerSystemsStudent which are described below. Make sure to show all the members (member variables and member functions) of the classes on your UML diagram. Save your UML diagram and also export it as a PNG. B) Second, write a program that contains the following parts. Write each class interface and implementation, in a different .h and .cpp file, respectively. a) Create...

  • need Algorithm and java code, please don't post only one!! Define a class called Counter. An...

    need Algorithm and java code, please don't post only one!! Define a class called Counter. An object of this class is used to count things so it records a count that is a non-negative whole number. Include methods to set the counter to 0, to increase the counter by 1, and to decrease the counter by 1. Be sure that no method allows the value of the counter to become negative. Also include an accessor method that returns the current...

  • Create a UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? 3. Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two...

  • java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome: ...

    java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome:  Student will demonstrate the ability to understand inheritance Program Specifications: Programming assignment: Classes and Inheritance You are to pick your own theme for a new Parent class. You can pick from one of the following:  Person  Automobile  Animal  If you choose Person, you will create a subclass of Person called Student.  If you choose Automobile, you will create a...

  • The purpose of this homework is to practice OOP programming covering Inheritance in java. The scenario...

    The purpose of this homework is to practice OOP programming covering Inheritance in java. The scenario is to design an online shopping system for a local supermarket (e.g., Europa Foods Supermarket or Wang Long Oriental Supermarket) and is mostly concentrated on the product registration system. Design and draw a UML diagram, and write the code for the following classes: ID: The identification number must start with 1 and follows with 6 numbers, e.g., “1123456”. Description, e.g. “Banana” Recommended Price per...

  • Code in JAVA UML //TEST HARNESS //DO NOT CHANGE CODE FOR TEST HARNESS import java.util.Scanner; //...

    Code in JAVA UML //TEST HARNESS //DO NOT CHANGE CODE FOR TEST HARNESS import java.util.Scanner; // Scanner class to support user input public class TestPetHierarchy { /* * All the 'work' of the process takes place in the main method. This is actually poor design/structure, * but we will use this (very simple) form to begin the semester... */ public static void main( String[] args ) { /* * Variables required for processing */ Scanner input = new Scanner( System.in...

  • I have some problems with my code. In Mimer I get this result for the code...

    I have some problems with my code. In Mimer I get this result for the code bellow: tests.cpp:29: Failure The difference between p1.distanceTo(p2) and 5.0 is 0.75735931288071523, which exceeds EPS, where p1.distanceTo(p2) evaluates to 4.2426406871192848, 5.0 evaluates to 5, and EPS evaluates to 1.0000000000000001e-05. Can I get some help what I did wrong here, The assignment is below: Write a class called Point that contains two doubles that represent its x- and y-coordinates. It should have get and set methods...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT