Question

You are a senior team lead for a fledgling software engineering firm. In order to meet...

You are a senior team lead for a fledgling software engineering firm. In order to meet a tight deadline, you have hired a freelance programmer to remotely assist you and your small team. To ensure that this freelancer can deliver usable code, you ask them to submit a simple header file named test.h that contains a definition for a class named Test. You specify that this Test class must contain one private, bool-typed member variable named b and a corresponding pair of public accessor/mutator function declarations. Within 24 hours, this freelancer delivers the following header file:

#ifndef TEST
#define TEST

class Test
{

bool b = true; //Initialized to true by default;

public:

//Accessor function that returns private
//member variable b back to the calling function
bool get_b();

//Mutator function that assigns value of bParam
//to the private member variable b
void set_b(bool bParam);

};

#endif


Implementation

You decide to test the correctness of this class definition by creating two files: an implementation file named test.cpp and a program file named TestProgram.cpp. You #include the above header file in both files


In test.cpp, you perform two tasks:

1) Define the accessor function of the Test class
2. Define the mutator function of the Test class


In TestProgram.cpp, you perform three tasks:


1) Define the main function to create a Test object named tObj
2) In main, call tObj's set_b function, passing in a value of false as the argument
3) In main, print out the value returned by calling get_b to the terminal

Once you perform these tasks, you compile and link TestProgram.cpp with your test.o file. Upon executing your a.out file and verifying that a value of 0 (or false) is output to the terminal, you can reasonably assume that this freelancer has satisfied your baseline requirements.


0 0
Add a comment Improve this question Transcribed image text
Answer #1

Given below is the code for the question. Please do rate the answer if it helped. Thank you.


test.h
-----
#ifndef TEST
#define TEST

class Test
{

bool b = true; //Initialized to true by default;

public:

//Accessor function that returns private
//member variable b back to the calling function
bool get_b();

//Mutator function that assigns value of bParam
//to the private member variable b
void set_b(bool bParam);

};

#endif

test.cpp
------

#include "test.h"

bool Test::get_b(){
   return b;
}

void Test::set_b(bool bParam){
   b = bParam;
}

TestProgram.cpp
------
#include <iostream>
#include "test.h"
using namespace std;
int main(){
   Test tObj;
   tObj.set_b(false);
   cout << tObj.get_b() << endl;
   return 0;
}


output
---
0

Add a comment
Know the answer?
Add Answer to:
You are a senior team lead for a fledgling software engineering firm. In order to meet...
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
  • 1a. Create a class named Inventory - Separate declaration from implementation (i.e. Header and CPP files)...

    1a. Create a class named Inventory - Separate declaration from implementation (i.e. Header and CPP files) 1b. Add the following private member variables - a int variable named itemNumber - an int variable named quantity - a double variable named cost - a double variable named totalCost. Total cost is defined as quantity X cost. - updateTotalCost() which takes no arguments and sets the values of the variable totalCost. 1c. Add the following public functions: - Accessor and Mutators for...

  • Write three object-oriented classes to simulate your own kind of team in which a senior member...

    Write three object-oriented classes to simulate your own kind of team in which a senior member type can give orders to a junior member type object, but both senior and junior members are team members. So, there is a general team member type, but also two specific types that inherit from that general type: one senior and one junior. Write a Python object-oriented class definition that is a generic member of your team. For this writeup we call it X....

  • So on this assignment... I have the main.cpp file, the fan.cpp file, and the fan.h file...

    So on this assignment... I have the main.cpp file, the fan.cpp file, and the fan.h file created and open in Dev C++. However, every time I try to compile I get a series of undefined reference to errors. Any advice is much appreciated!!! (45 pts) Work Programming Exercise 9.2 (class Fan) in the textbook on page 367. Additional specifications: • Use separate header and implementation files. • The main program (not the functions) should display the values of Speed, On,...

  • OUTCOMES After you finish this assignment, you will be able to do the following: Define an...

    OUTCOMES After you finish this assignment, you will be able to do the following: Define an abstract class Create concrete classes from an abstract class Overload an operator Split classes into .h and .cpp files Open files for reading Write to files Use output manipulators such as setw, fixed, and setprecision DESCRIPTION A binary arithmetic operation takes two double operands (left and right) to perform addition, subtraction, multiplication, or division on. For example, 10 + 11 is an addition (+)...

  • The class declaration (interface) and the function definitions (implementation) must be in separate files - the...

    The class declaration (interface) and the function definitions (implementation) must be in separate files - the interface or "header" file has a .hpp extension and the implementation has a .cpp extension. As usual, all data members should be private. Write a class called BankAccount that has: a string data member called customerName, a string data member called customerID, and a double data member called customerBalance a constructor that takes two strings and a double (name, ID, balance) and uses them...

  • Implement the following class in interface and implementation files. A separate file (the main project file)...

    Implement the following class in interface and implementation files. A separate file (the main project file) shall have the main function that exercises this class. Create a class named Student that has three member variables: name - string that stores the name of the student numClasses - integer that tracks how many courses the student is currently enrolled in, this number must be between 1 and 100 ClassList - an array of strings of size 100 used to store the...

  • PLEASE COMPLETE IN C++ LANGUAGE Location row : int = -1 col : int = -1...

    PLEASE COMPLETE IN C++ LANGUAGE Location row : int = -1 col : int = -1 setLocation(row : int, col : int) getRow(): int getColl): int isEmpty(): bool Details Write all the code necessary to implement the Location class as shown in the UML Class Diagram to the right. Do this in a project named snake (we'll continue adding files to this project as the term progresses). Your class definition and implementation should be in separate files. When complete, you...

  • .Your solution must include header, implementation file, and test files .In C++ write a code to...

    .Your solution must include header, implementation file, and test files .In C++ write a code to Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members for Height, Width and center point, while a square and circle might have only a center point and an edge length or radius. In a well-designed system, these would be derived from a common class, Figure. You are to...

  • Design a class that contains: we have to make 3 files header file , one .cpp...

    Design a class that contains: we have to make 3 files header file , one .cpp file for function and one more main cpp file 9.3 (The Account class) Design a class named Account that contains: An int data field named id for the account. A double data field named balance for the account. A double data field named annualInterestRate that stores the current interest rate. A no-arg constructor that creates a default account with id 0, balance 0, and...

  • COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see...

    COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see which professor has the highest rating according to student input. You will create a ProfessorRating class consisting of professor Name and three ratings. The three ratings are used to evaluate easiness, helpfulness, and clarity. The value for each rating is in the range of 1 to 5, with 1 being the lowest and 5 being the highest. Your program should contain the following functionalities:...

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