Question

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.
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:

Ram size: 64 Is GPU present: 1 GPU type: GTX RX1000 Operating System: Windows Process returned θ (0x0) execution time : 0.200

Add a comment
Know the answer?
Add Answer to:
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...
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,...

    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.

  • JAVA - Abstraction and Encapsulation are one pillar of OOP (Object Oriented Programming). Another is inheritance...

    JAVA - Abstraction and Encapsulation are one pillar of OOP (Object Oriented Programming). Another is inheritance and polymorphism. In this assignment we will use inheritance and polymorphism to solve a problem. Part (a) of the figure below shows a symbolic representation of an electric circuit called an amplifier. The input to the amplifier is the voltage vi and the output is the voltage vo. The output of an amplifier is proportional to the input. The constant of proportionality is called...

  • 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...

  • 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...

  • Programming Assignment 5: UML Diagram Objectives: After successfully completing this assignment, students will practice Object Oriented...

    Programming Assignment 5: UML Diagram Objectives: After successfully completing this assignment, students will practice Object Oriented design by creating an UML diagram for a Java program. Program Statement: Bank System You were asked to create a simple UML diagram for a bank system. Each bank has a specific identification number, a name, and a location that needs to be stored. Tellers serve customers’ loans, checking and savings accounts. The bank must know each tellers’ name and identification number for record...

  • Page 1/2 ECE25100 Object Oriented Programming Lab 8: Inheritance Description: The purpose of this lab is...

    Page 1/2 ECE25100 Object Oriented Programming Lab 8: Inheritance Description: The purpose of this lab is to practice inheritance. To get credit for the lab, you need to demonstrate to the student helper that you have completed all the requirements. Question 1: Consider the following detailed inheritance hierarchy diagram in Fig. 1. 1) The Person.java constructor has two String parameters, a first name and a last name. The constructor initializes the email address to the first letter of the first...

  • Background: This assignment deals with inheritance. Inheritance is one of the major principles of object-oriented programming....

    Background: This assignment deals with inheritance. Inheritance is one of the major principles of object-oriented programming. In C++, one of the biggest goals is "code reuse". Inheritance accomplishes this. In order to get inheritance working in C++, you must get both the structure of your .h files as well as the implementation of your constructor correct. Constructor implementations must use an initialization list. Please review the book and the online content on these issues so you know how it works...

  • Purpose: To write an Object-Oriented application using abstraction, inheritance, encapsulation, and polymorphism to handle an inheritance...

    Purpose: To write an Object-Oriented application using abstraction, inheritance, encapsulation, and polymorphism to handle an inheritance structure of various shapes. Details: Implement the following Shape hierarchy: a box around each shape name and arrows pointing to the shape from each (Circle, Square, Triangle) Shape Circle Square Triangle    Use the following as a guide: The Shape class should be abstract and contain two abstract methods: getArea – Which calculates the area of the shape and returns that value as a...

  • 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...

  • Objectives Make the transition to object oriented programming. Go over some of the basics concepts: Classes...

    Objectives Make the transition to object oriented programming. Go over some of the basics concepts: Classes Instance variables Methods Object state The keyword "this", what it does toString method Introduction Phase 1 Review the following Java programs as an example of a Java class and client code that uses it: MimicOct.java and UnderTheSea.java. All of you have been working with classes in Java. One of the most important things to know about classes is that they are actually blueprints for objects. They basically...

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