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

  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • 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 Object Array With 2 Elements In 1 Object

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

  • I NEED HELP with this. please create a UML diagram. I need a simple code to...

    I NEED HELP with this. please create a UML diagram. I need a simple code to solve the problem.   The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should...

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
ADVERTISEMENT