Each of the following class declarations has errors. Locate as many as you can.
A) class Box
{
private:
double width;
double length;
double height;
public:
Box(double w, 1, h)
{ width =w; length = 1; height = h; }
Box (Box b) // Copy constructor
{ width = b.width;
length = b.length;
height = b.height; }
... Other member functions follow ...
};
B). class Circle
{
private:
double diameter;
int centerX;
int centerY;
public:
Circle(double d, int x, int y)
{ diameter = d; centerX = x; centerY = y; }
// Overloaded = operator
void Circle=(Circle &right)
{ diameter = right.diameter;
centerX = right.centerX;
centerY = right.centerY; }
... Other member functions follow ...
};
C). class Point
{
private:
int xCoord;
int yCoord;
public:
Point (int x, int y)
{ xCoord = x; yCoord = y; }
// Overloaded + operator
void operator+(const &Point Right)
{ xCoord += right.xCoord;
yCoord += right.yCoord;
};
... Other member functions follow...
};
D) class Box
{
private:
double width;
double length;
double height;
public:
Box(double w, 1, h)
{ width = w; length = 1; height = h; }
// Overloaded prefix ++operator
void operator++ ()
{ ++width; ++length; }
// Overloaded postfix ++ operator
void operator++ ()
{width++; length++; }
... Other member functions follow ...
};
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
Starting Out with Java: Early Objects (6th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Software Engineering (10th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Database Concepts (7th Edition)
- #pyhton programing topic: Introduction to Method and Designing class Method overloading & Constructor overloading ------------------ please find the attached imagearrow_forwardThe following class declaration has errors. Locate as many as you can. class Box { private: double width; double length; double height; public: Box(double w, l, h){ width = w; length = l; height = h; } Box(Box b) // Copy constructor {width = b.width; length = b.length; height = b.height; } ... Other member functions follow ...};arrow_forwardProblem: Employee and ProductionWorker Classes Write a python class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: • Shift number (an integer, such as 1, 2, or 3)• Hourly pay rateThe workday is divided into two shifts: day and night. The shift attribute will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write the appropriate accessor and mutator methods for this class. Once you have written the class, write a program that creates an object of the ProductionWorker class, and prompts the user to enter data for each of the object’s data attributes. Store the data in the object, then use the object’s accessor methods to retrieve it and display it on the screen Note: The program should be written in python. Sample Input/Output: Enter the name: Ahmed Al-AliEnter the ID number: 12345Enter the department:…arrow_forward
- C++ Programming Assignment 6 Dynamic Pets The objective of this lab is to demonstrate dynamic allocation and deallocation of memory. Instructions: Write a class called Pet that contains an animal’s name, type, and weight. Include a default constructor and destructor for the class. The constructor should print out the following message: “Creating a new pet”. The destructor should print out the following message: “In the Pet destructor.” Include appropriate get/set functions for the class. In main(), prompt the user to enter the number of pets in his or her household. Dynamically create a built-in array based on this number (not a vector or object of the array class) to hold pointers to Pet objects. Construct a loop in main() that executes once for each of the number of pets that the user indicated. Within this loop, ask the user to enter the name and type of pet. Using a random number generator, generate a weight between 1-100 pounds. Seed this random number generator with 100.…arrow_forwardCruise Recreational Activities Example Recreational activities include things like aerobics, shuffle board, and swimming. Each activity is identified by an activity code and includes other information such as description. Classes are offered for each activity. A class is uniquely identified by a combination of the activity code and the day/time at which it is held. It is assumed that a specific class will never be offered for the same activity at the same day and time, although it could be offered on a different day and/or time. Other information about a class includes the enrollment limit and the current enrollment count. A class will never include more than one activity. A passenger can sign up for a class as long as there is sufficient room in the class. Passengers are identified by a unique passenger number. Other information stored about passengers includes name, address, and age. Passengers have no limit on the number and type of classes they can sign up for. When they…arrow_forwardTrue or false A class can have self-referential data membersarrow_forward
- Each of the following class declarations or programs contain errors. Find as many as possible. 73. class Circle: { private double centerX; double centerY; double radius; public setCenter(double, double); setRadius(double); } 74. #include using namespace std; Class Moon; { Private; double earthWeight; double moonWeight; Public; moonWeight(double ew); { earthWeight = ew; moonWeight = earthWeight / 6; } double getMoonWeight(); { return moonWeight; } }arrow_forwardTrue or False It is legal to write a class without any constructors.arrow_forwardclockType.h file provided //clockType.h, the specification file for the class clockType#ifndef H_ClockType#define H_ClockType class clockType {public: void setTime(int hours, int minutes, int seconds); //Function to set the time. //The time is set according to the parameters. //Postcondition: hr = hours; min = minutes; // sec = seconds // The function checks whether the values of // hours, minutes, and seconds are valid. If a // value is invalid, the default value 0 is // assigned. void getTime(int& hours, int& minutes, int& seconds) const; //Function to return the time. //Postcondition: hours = hr; minutes = min; // seconds = sec void printTime() const; //Function to print the time. //Postcondition: The time is printed in the form // hh:mm:ss. void incrementSeconds(); //Function to increment the time by one…arrow_forward
- Car Class in C++ language whole task is in the picturearrow_forward#pyhton programing topic: Introduction to Method and Designing class Method overloading & Constructor overloading ------------------ please find the attached imagearrow_forward#pyhton programing topic: Introduction to Method and Designing class Method overloading & Constructor overloading ------------------ please find the attached imagearrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning