Question

C++ Do not use constructors Create a class named Coord in C++ Class has 3 private...

C++

Do not use constructors

Create a class named Coord in C++

Class has 3 private data items

              int xCoord;

              int yCoord;

              int zCoord;

write the setters and getters. They should be inline functions

              void setXCoord(int)             void setYCoord(int)            void setZCoord(int)

              int getXCoord()                     int getYCoord()                   int getZCoord()

write a member function named void display() that displays the data items in the following format

     blank line

     xCoord is                          ????????

     yCoord is                          ????????

     zCoord is                          ????????

    Blank line

Example

     blank line

     xCoord is                          101

     yCoord is                          -234

     zCoord is                          10

    Blank line

Homework Answers

Answer #1
class Coord {
  private:
int xCoord;
int yCoord;
int zCoord;

  public:
void setXCoord(int x) {xCoord = x;}
void setYCoord(int x) {yCoord = x;}
void setZCoord(int x) {zCoord = x;}
int getXCoord() {return xCoord; }
int getYCoord() {return yCoord; }
int getZCoord() {return zCoord; }

void display()
{
cout<<'\n';
cout<<"xCoord is"<<'\t'<<xCoord<<'\n';
cout<<"yCoord is"<<'\t'<<yCoord<<'\n';
cout<<"zCoord is"<<'\t'<<zCoord<<'\n';
cout<<'\n';
}

};
Know the answer?
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
Similar Questions
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
write a c++ program A class called car (as shown in the class diagram) contains: o...
write a c++ program A class called car (as shown in the class diagram) contains: o Four private variables: carId (int), carType (String), carSpeed (int) and numOfCars (int). numOfCars is a static counter that should be  Incremented whenever a new Car object is created.  Decremented whenever a Car object is destructed. o Two constructors (parametrized and copy constructor) and one destructor. o Getters and setters for the Car type, ID, and speed. And static getter function for numOfCars....
Create a class called time that has three data members hours, minutes, and seconds. The class...
Create a class called time that has three data members hours, minutes, and seconds. The class has the following member functions: - Overloaded Constructors - Display function to display it, in 11:59:59 format. - SetTime() - IsValid(): Check if the time is valid or not - AddTime(Time t1, Time t2): Add two time values passed as a parameter leaving the result in third time variable. - Increment(): Tells what will be time after a second - Decrement(): Tells what was...
IntNode class I am providing the IntNode class you are required to use. Place this class...
IntNode class I am providing the IntNode class you are required to use. Place this class definition within the IntList.h file exactly as is. Make sure you place it above the definition of your IntList class. Notice that you will not code an implementation file for the IntNode class. The IntNode constructor has been defined inline (within the class declaration). Do not write any other functions for the IntNode class. Use as is. struct IntNode { int data; IntNode *next;...
Design a Java class named Polygon that contains:  A private int data field named numSides...
Design a Java class named Polygon that contains:  A private int data field named numSides that defines the number of sides of the polygon. The default value should be 4.  A private double data field named sideLength that defines the length of each side. The default value should be 5.0.  A private double data field named xCoord that defines the x-coordinate of the center of the polygon. The default value should be 0.0.  A private double...
c++ Design a class named Account that contains (keep the data fields private): a) An int...
c++ Design a class named Account that contains (keep the data fields private): a) An int data field named id for the account. b) A double data field named balance for the account. c) A double data field named annualInterestRate that stores the current interest rate. d) A no-arg constructor that creates a default account with id 0, balance 0, and annualInterestRate 0. e) The accessor and mutator functions for id, balance, and annualInterestRate. f) A function named getMonthlyInterestRate() that...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields,...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields, as well as the methods for the Inventory class (object). Be sure your Inventory class defines the private data fields, at least one constructor, accessor and mutator methods, method overloading (to handle the data coming into the Inventory class as either a String and/or int/float), as well as all of the methods (methods to calculate) to manipulate the Inventory class (object). The data fields...
in C++ Define a class bank account with proper constructors, accessors, mutators, and other member functions....
in C++ Define a class bank account with proper constructors, accessors, mutators, and other member functions. The class will be store money expressed in dollars and cents. The class should have following data members (fname, lname, accountNum, balance, dollars, cents).Write A function to print out the object bank account info.The class should implement two member functions for deposit and withdrawal. Overload the + operator, so that adding two objects of this class works. please respond quickly and clearly, thank you.
In C++ PART 1: Write a constructor for a class data type named Test that has...
In C++ PART 1: Write a constructor for a class data type named Test that has the following two member variables: double arr*; int size; The constructor should take one argument for the size and then dynamically allocate an array of that size. PART 2: Write a destructor for the Test class.
ALL CODE MUST BE IN C++ Before you begin, you must write yourself a LinkedList class...
ALL CODE MUST BE IN C++ Before you begin, you must write yourself a LinkedList class and a Node class (please name your classes exactly ​as I did here). Please follow the below specifications for the two classes. Node.cpp ● This must be a generic class. ● Should contain a generic member variable that holds the nodes value. ● Should contain a next and prev Node* as denoted here. ● All member variables should be private. ● Use public and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT