What does it mean to use the keyword enum? when using this in a class (OOP)?
Q: Use the following partial class definitions to answer the questions a-c…
A: 1 a) following is true with respect to A1, A2 and A3? A2 and A3 are both subclasses of A1 A3 is a…
Q: Write a Rational class. Recall a rational number is a rational number, composed of two integers with…
A: #include <iostream>#include <string>#include <stdlib.h>using namespace std;class…
Q: The following code may, or may not, work. However the bigger issue is that it doesn't give good…
A: Required: The following code may, or may not, work. However the bigger issue is that it doesn't…
Q: The following C++ code consists of an error. What is the cause of the error? class Human{ public:…
A: This is based on the concept of virtual functions in C++
Q: Q1: Write a complete JAVA program that carries out the following task s: Declare a class Video with…
A: 1. Program Approach: Import necessary package Create class video Data Members created in class…
Q: 2.Create a class in c++ called rectangle which has following mebers- Private-int height,int width…
A: In this question we have to execute a C++ program where we need to create a rectangle class and…
Q: Consider the following class and answer questions after this class #include using…
A: Note: The answers of the first three subparts are shown below. Please repost the remaining subpart…
Q: 2) You must implement the pieces of the below classes on the following pages. You only should…
A: To Complete the given application i have implemented all the methods of the Point and Rectangle…
Q: Demonstrate your class works with a main() function that instantiates an array of three Rectangle…
A: #include <iostream>using namespace std;class Rectangle{private: double width; double…
Q: Read out the following program carefully and explain each mentioned section (colored) of this…
A: Inheritance is a concept in which one class (derived class) acquires properties, such as data…
Q: Previous Exercise to help with answering the question which is below | Write the header file (.h…
A: Answer :
Q: The following C++ code consists of an error. What is the cause of the error? class Human{ public:…
A: ERROR: cannot convert ‘Teacher*’ to ‘Human*’ in assignment h=&t; | ^~ |…
Q: It is a library service program to issue book based on ISBN and book title. Identify the code smells…
A: Consider the Borrower class.
Q: Assume that you are applying “testing” and “inspection”, the two defect finding methods in the…
A: The answer is as follows.
Q: What is the output of the following code? Include a description of what happens. 1 class Main {…
A: In the main method, an object of SecondClass with 27,18 as its attributes is created. When…
Q: Please code in C++ and U can take time for this one and please follows all the instruction. Thank…
A: We will use OOPS based technique to code the problem in C++ language.
Q: Reuse your Car class . In a main, build an object of that class, and print out the object using…
A: public class Car { //instance variables private int odometer; private String make;…
Q: Need code in C++. I have answer till part 7,please go through the code and correct it if you find…
A: A class is a user defined blueprint or prototype from which objects are created. It represents the…
Q: Use the following partial class definitions to answer the question: public class A1 {…
A: Dear Student, Only public and protected members of the parent class can be inherited by the parent…
Q: Which of the following lines of code would you use in an implementation of the destructor? a) none…
A: in the given code: class SwimmingPool { private: int area; int gallons; public:…
Q: Q4. Given below is the code for the controlling class with constructor overloading, analyse the code…
A: Constructor overloading a concept of having more than one constructors in class with different…
Q: Q 1: Access class members from the same package Note: ClassA and ClassB in this question are in the…
A: In order to create a variable that is not accessible outside class we must declare it as private. If…
Q: #include class A { private: class B { public: B() { x = 1; } int x;…
A: Note: - As per our honor code we only answer 3 subparts. Please repost the question accordingly.…
Q: Consider the following code: class A { public: void printChar() { cout printChar();…
A: The mechanism of developing and implementing an executable computer program to achieve a particular…
Q: Write a lambda or method reference for each of the following tasks: a) Write a lambda that can be…
A: As per Bartleby guidelines “Since you have posted a question with multiple sub-parts, we will solve…
Q: 5- When de we need to use private keyword in C++ class? 6- A derived class can be a base class for…
A: 5) When you need private keyword in c++ class 6) Derived class can be a base class for other class…
Q: PYTHON 11.1 Tiny Sales Company: Phase 1 (1) Build the ItemToPurchase class with the following…
A: I have an intro class in Python where part of the instructions are: (2) Build the ShoppingCart…
Q: (d) Complete the following code by writing the constructor and toString method in Sub class to print…
A: Provided the Rewritten code for both of the above given questions where highlighted part represents…
Q: Question 01: Write a Program to design a class complex to represent complex numbers. Create an input…
A: As per expert guidelines , when there are unrelated multiple questions, I am supposed to answer the…
Q: Assume we have a class called Animals and within this class we have a method called toString(), and…
A:
Q: This is my code in c++. When the chosen class is full I want the code to automatically assign it to…
A: Given Code : The C++ code the seat booking in the three classes named : first-class business class…
Q: using c++: Write a class service (servant_name, tip, and the static total_tip and static…
A: /******************************************************************************…
Q: rite a java program that uses a structure to store the information about the Items in a retail…
A: Below is the required java program. Program Approach: Import necessary packages to get the…
Q: Refer to the following code and answer the questions on the right: 1 class Product: store_name =…
A: Ans 1: The output if the given lines of code are executed after the last line is : class Product:…
Q: Write the definition of the default constructor of YClass so that the instance variables of YClass…
A: public YClass() { this.a=0; this.b=0; }
Q: class A{}; class B{}; int main() { A obl,ob2; B ob3; ob3=ob2; } (a)Why does Overloading occur? Is…
A: Here i explain it: ============================= given code we run it so saw the compilation error :…
Q: Consider the code given below. #include using namespace std; class myclass { private: int x; public:…
A: The problem is based on finding the statement containing the error.
Q: Answer the following questions for the program below: 1 #include <iostream>2 using namespace…
A: Given: Answer the following questions for the program below: 1 #include <iostream>2 using…
Q: Study the following definition of class testType, and answer the question be class testType public:…
A: #include <bits/stdc++.h>using namespace std; class testype {public: void setdata(double f,…
Q: class Test4 { int i; Test4 (int m){ i = m; class Test5 extends Test4{ private int j; Il add a…
A: The program illustrates the inheritance, polymorphism (overloading), and super keyword. Test4 is a…
Q: use the following partial class definitions: public class A1 { public int x; private int y; public…
A: Given that, Which of the following lists of instance data are accessible in class A2?a) x, y, z, a,…
Q: Consider the following code snippet. How many times do you expect "In the constructor!" to be…
A: Please find the answer below:
Q: Create a lecturer class with member -data name (name) and department (department). For the Lecturer…
A: The programming instructions are as follows: Create a class lecturer. The data members are a name…
Q: class Auto { String make="Unknown"; String model = "Unknown": int year = 0; float price = 0.0;…
A: So to create a object of this given class we have to use new keyword But to set the model = "java"…
Q: Write a class service (servant_name, tip, and the static total_tip and static number_of_servatns )…
A: Write a class service (servant_name, tip, and the static total_tip and staticnumber_of_servatns…
Q: Fill in the appropriate Java and then answer the questions
A: Here is the full and complete code shown below. -------------------------------------- Java Code…
Q: Implement “SoftwareEngineer” and “CheifEngineer” class derived from “Employee” class with necessary…
A: Here I have created both SoftwareEngineer and CheifEngineer classes. In both the classes, the same…
Q: In C++ Create a class: “Prime” with private data members: upper_limit (int), lower_limit (int) and…
A: Input upper_limit and lower_limit from user and assign the larger number as upper_limit and smaller…
Q: IN C++, Create a class called Invoice that a hardware store might use to represent an invoice for an…
A: Question given: Create a class for get invoice of a hardware items. Class has four instance…
What does it mean to use the keyword enum? when using this in a class (OOP)?
For example (also not a good example, but a reference to what I mean):
#include "box.h"
using namespace std;
enum class Box{
Member,
Admin,
Employee
};
#include "box.h"
#include <iostream>
using namespace std;
int main(){
if (answer == 1)
string admin_name Box::Admin;
court << "You are an " << admin_name << endl;
}
Can you explain to me in this case what enum is used for in this case? In this part, I cannot understand the usage in this case.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
- 7- Every class member is by default. (public, private, not public nor private) 8- Create an instance of the following class and call its methods. class Exam{ int grade; public: void seta (int b) (grade=b; } int geta () {return grade; } }; 9- When the word const is put before the variable definition, what does that mean? 10- How to concatenate two strings in C++ language? C++Q 1: Access class members from the same package Note: ClassA and ClassB in this question are in the same package. public class ClassB { public int x = 1; int y = 2; private int z =3; } public class ClassA { public static void main(String[] args) { ClassB cb = new ClassB(); // System.out.print(cb.x); /* 1 */ // System.out.print(cb.y); /* 2 */ // System.out.print(cb.z); /* 3 */ } } 1.1- Which statement(s) are true? Choose all that apply. a. If statement 1 is uncommented, the code prints "1" to the output. b. If statement 2 is uncommented, the code prints "2" to the output. c. If statement 3 is uncommented, the code prints "3" to the output. .d. This code does not compile 1.2- Try to do the following: • Declare a character type variable myChar in the class ClassB, the variable myChar shouldn't be accessible through the object cb. Add a statement to the classA to test whether myChar is accessible.**please see question attached** (previous program below) #include <iostream>using namespace std;class House{//instance variablesprivate:string location;int price; public://constructorsHouse(){location = "TBD";price = 0;}House(string location,int price){this->location = location;this->price = price;}//Get and set methodsvoid setLocation(string location){this->location = location;}string getLocation(){return location;}void setPrice(int price){this->price = price;}int getPrice(){return price;} };//member functionvoid output(House a){cout <<"Location: " << a.getLocation()<<endl;cout <<"Price: "<<a.getPrice()<<endl;}int main(){House a("1234 qcc st, Bayside, NY",1000000);output(a);House b;output(b); return 0;}
- Nutritional information (classes/constructors) PYTHON ONLY Complete the FoodItem class by adding a constructor to initialize a food item. The constructor should initialize the name (a string) to "None" and all other instance attributes to 0.0 by default. If the constructor is called with a food name, grams of fat, grams of carbohydrates, and grams of protein, the constructor should assign each instance attribute with the appropriate parameter value. The given program accepts as input a food item name, fat, carbs, and protein and the number of servings. The program creates a food item using the constructor parameters' default values and a food item using the input values. The program outputs the nutritional information and calories per serving for both food items. Ex: If the input is: M&M's10.034.02.01.0 where M&M's is the food name, 10.0 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is:…class GradedActivity { private: double score; public: GradedActivity() { score = 0.0; } GradedActivity(double s) { score = s; } void setScore(double s) { score = s; } double getScore() { return score; } char getLetterGrade() const; }; Implement the GradedActivity class above. In this C++ assignment, create a new class Assignment which is derived from GradedActivity. It should have three private member ints for 3 different parts of an assignment score: functionality (max 50 points), efficiency (max 25 points), and style (max 25 points). Create member function set() in Assignment which takes three parameter ints and sets the member variables. It should also set its score member, which is inherited from GradedActivity, using the setScore() function, to functionality + efficiency + style. Signature: void Assignment::set(int, int, int) Create a main program which instantiates an Assignment, asks the user…JAVA Language Caesar Shift Question: Modify the Caesar class so that it will allow various sized shifts to be used, instead of just a shift of size 3. (Hint: Use an instance variable in the Caesar class to represent the shift, add a constructor to set it, and change the encode method to use it.) import java.util.*; public class TestCipher { public static void main(String[] args) { int shift = 7; Caesar caesar = new Caesar(); String text = "hello world"; String encryptTxt = caesar.encrypt(text); System.out.println(text + " encrypted with shift " + shift + " is " + encryptTxt); } } abstract class Cipher { public String encrypt(String s) { StringBuffer result = new StringBuffer(""); // Use a StringBuffer StringTokenizer words = new StringTokenizer(s); // Break s into its words while (words.hasMoreTokens()) { // For each word in s…
- #include #include using namespace std; class Painting { public: //define the constructor }; int main() { string name; cin >> name; Painting painting(name); return 0; }Please help with the following: C# .NET change the main class so that the user is the one that as to put the name Write a driver class (app) that prompts for the person’s data input, instantiates an object of class HeartRates and displays the patient’s information from that object by calling the DisplayPatientRecord, method. MAIN CLASS---------------------- static void Main(string[] args) { // instance of patient record with each of the 4 parameters taking in a value HeartRates heartRate = new HeartRates("James", "Kill", 1988, 2021); heartRate.DisplayPatientRecord(); // call the method to display The Patient Record } CLASS HeartRATES------------------- class HeartRates { //class attributes private private string _First_Name; private string _Last_Name; private int _Birth_Year; private int _Current_Year; // Constructor which receives private parameters to initialize variables public HeartRates(string First_Name, string Last_Name, int Birth_Year, int Current_Year) { _First_Name =…C# languageCreate a class for “Plane” having functionalities (methods) startengine(), fly() and land(). When ever engine starts it should reset the attribute TTK (Total travel kilometer) to zero and attribute Fuel to 100. On fly() it should add 10 kilometers if the Fuel attribute is greater than zero and decrement Fuel by 20.On land() it should print total distance covered. Write the code providing all necessary details. And then show working object of Plane in main().
- #include <iostream> using namespace std; class Rectangle { // define class public: Rectangle() { length = 0; width = 0; } // constructor float getlength() { return length; } // return length float getWidth() { return width; } // return width float area() { return length* width; } // return area float perimeter() { return 2 * length + 2 * width; } void setValues(float, float); private: float length, width; }; void Rectangle::setValues(float len, float wid) { if (len <= 0 || len >= 20) { cout << "Enter new value for length "; cin >> len; } length = len; if (wid <= 0 || wid >= 20) { cout << "Enter new value for width "; cin >> wid; } width = wid; } int main() { float length, width; Rectangle r; cout << "Enter a value for length and width between 0 and…imaginary.h#pragma once#include <iostream>using namespace std; class Imaginary { private: int coeff; //If 5, then means 5i public: Imaginary(); Imaginary(int new_coeff); int get_coeff() const; Imaginary operator+(const Imaginary& rhs) const; //This is a "constant method" Imaginary operator-(const Imaginary& rhs) const; int operator*(const Imaginary& rhs) const; Imaginary operator*(const int& rhs) const; Imaginary operator=(const int& rhs); Imaginary operator=(const Imaginary& rhs); bool operator==(const Imaginary& rhs) const; friend ostream& operator<<(ostream& lhs, const Imaginary& rhs); friend istream& operator>>(istream& lhs, Imaginary& rhs);}; imaginary.cc#include "imaginary.h"#include <iomanip>using namespace std; //Sample Code - I have done the addition operator for you so you can see//what a…Modify the Student class presented above as follows. Each student object should contain the scores for three (3) tests. (1) Provide a constructor that sets all instance values based on parameter values. (2) ✓ Overload the constructor such that each test score is assumed to be initially zero. (5) Provide a method called setTestScore that accepts two (2) parameters: the test number (1 through 3) and the score. Also provide a method called getTestScore that accepts the test number and returns the appropriate score. (6) Provide a method called average that computes and returns the average test score for the student. (3) Modify the display method such that the test scores and average are included in the description of the students. (5) Implement the class to exercise the methods of Student. (8) NOTE WELL ✓ Ensure that your programs are documented (comments) as needed ✓ Make certain that your programs are debugged and working before submitting