Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ 1. (TCO 8) Briefly describe best practices as it relates to naming variables

ID: 3850157 • Letter: C

Question

c++

1. (TCO 8) Briefly describe best practices as it relates to naming variables and their associated accessor/mutator properties. (Points : 18)

Question 2.2. (TCO 2) Does Encapsulation imply Data/Information Hiding in object-oriented programming or vice versa? Are these two terms the same? Please explain.(Points : 18)

Question 3.3. (TCO 2) Given the following list of classes, attributes and methods,

·         identify which items are classes, which items are attributes and which items are methods;
·         identify which class each attribute and method belongs to; and
·         suggest a class hierarchy given your list of classes.

*Note - no particular capitalization scheme is used in the list below to differentiate between classes, methods, and attributes.

GainAltitude, DecreaseSpeed, Transportation, IdentificationNumber, MoveBackward, IncreaseSpeed, NumberOfDoors, Manufacturer, OpenHood, Airplane, MoveForward, MaximumAltitude, ComeInForLanding, MilesPerGallon, Car, NumberOfAisles (Points : 18)

Question 4.4. (TCO 7) How are pure virtual functions created? When a class contains one pure virtual function, what will happen? Can we still treat the class like a normal class? (Points : 18)

Question 5.5. (TCO 4) What are a bass class and a derived class? How do you distinguish between a base class and its derived classes? What programming technique shall you follow when the implementation of a base class method does not appropriately describe the behavior of a derived class object? (Points : 18)

Question 6.6. (TCO 6) Distinguish between inheriting interface and inheriting implementation. How do inheritance hierarchies designed for inheriting interface differ from those designed for inheriting implementation? (Points : 18)

Question 7.7. (TCO 2) Define and implement the overloaded constructors that support the following test function for a Rectangle class. The data members for the Rectangle class are:

• length - integer number
• width - integer number

int main()
{ Rectangle r1(); //r1 will take all default value
Rectangle r2(4, 5); //r2 will take all supplied value
Rectangle r3(10); //r3 will take supplied length, width will take default value
Rectangle r4= r2; //r4 will take the same value of r2

//the rest of the code
}
(Points : 22)

1. (TCO 8) Briefly describe best practices as it relates to naming variables and their associated accessor/mutator properties. (Points : 18)

      
      

Explanation / Answer

Resort to asking only question in one post. Still i will answer the first four of them. You can repost the rest of them.

Question 1:

The best practices to follow for naming variables are:
i) Do not use words that are reserved to name your variables. For example-class

ii) Names of variables shouldn't be pointless. They should have some meaning and be specific to the data that they are pointing to.

iii) Do not use lower case and upper case randomly. Either use all lower case, or all upper case or use camel casing.

iv) When using accessor and mutator functions, the name of the variable sent should be same as the variable recieved by the function.

v) Prefer shorter names over longer ones.

Question 2:
Data Encapsulation doesn't necessarily mean Data Hiding. But it is one of its aspects. Similarly, Data Hiding does not imply Data Encapsulation. These two terms are not the same. Encapsulation means grouping of things into one place, which can all later be reffered to as one name. When data is encapsulated, they data can indeed be sent from that encapsulation to another function.

Question 3:
The classes are:
Airplane,Car,Transportation

The methods are:
GainAltitude, DecreaseSpeed, MoveBackward, IncreaseSpeed, OpenHood, MoveForward, ComeInForLanding

The attributes are:

IdentificationNumber, NumberOfDoors, MaximumAltitude, MilesPerGallon, NumberOfAisles,Manufacturer

The class transportation contains:
Methods:

DecreaseSpeed, MoveBackward, IncreaseSpeed, MoveForward.

Attributes:

NumberOfDoors,Manufacturer

The class Car contains:

Methods:
OpenHood
Attributes:

IdentificationNumber

The class Airplane Contains:
Methods:

ComeInForLanding,GainAltitude

Attributes:
NumberOfAisles

The car and airplane class both derive from the Transportation class.

Question 4:
A virtual function is created by appending =0 to its declaration. Example:
class aman{

public :
void eat()=0;

}

If a class contains one virtual function, it becomes an abstract class.They are used to provide an interface to its sub classes. The classes inheriting from the abstract class must define the virtual function, or they too will become an abstract class. Thus we cannot use an abstract class as a normal class.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote