Question

My assignment is listed below. I already have the code complete, but I cannot figure out...

My assignment is listed below. I already have the code complete, but I cannot figure out how to complete this portion:
You must create a makefile to compile and build your program.

I can't figure out if I need to create a makefile, and if I do, what commands do I use for that?

Create a  ContactInfo class that contains the following member variables:

  • name
  • age
  • phoneNumber

The ContactInfo class should have a default constructor that sets name = "", phoneNumber = "", and age = 0.

The ContactInfo class should have a constructor that accepts the name and phone number as parameters and sets name = <value of parameter name>, aAge = 0, and phoneNumber = <value of parameter phone number>.

The ContactInfo class should have accessor and mutator functions for each member variable.

The ContactInfo class should have a function called canVote that returns a boolean. It will return true if age is >= 18. Otherwise, it will return false.

Create three instances of this class in the main function

Write a C++ function (outside of the class) that will display (as shown below in the sample run) an instance of the ContactInfo class. Call the function to display the three instances you created in the main function.

Make sure your program conforms to the following requirements:
1. This program should be called ContactInfoApp.cpp. The header file should be called ContactInfo.h and place member function definitions in ContactInfo.cpp. You must submit these three files.

Include the basic header in your program. (5 points deduction if missing)

2. Properly set up the ContactInfo class and declare three instances of ContactInfo (45 points)

3. Write a C++ program that will create and display (as shown below in the sample run) three instances of the ContactInfo class. (25 points).

4. Add comments wherever necessary. (5 points)

5. You must create a makefile to compile and build your program. In addition, you must test your program on linprog.cs.fsu.edu. (25 points)

(For this step - you must include a copy of the makefile and a copy of the terminal output from a compile and test run as shown below.)

Homework Answers

Answer #1

ContactInfo.h:

Code as text (to copy):

#ifndef _CONTACT_INFO_H_

#define _CONTACT_INFO_H_

#include <iostream>

#include <string>

using namespace std;

class ContactInfo {

private:

string name;

string phoneNumber;

int age;

public:

// default constructor

ContactInfo();

// parameterised constructor

ContactInfo(string _name, string _phoneNumber);

// accessor

string getName();

string getPhoneNumber();

int getAge();

// mutators

void setName(string _name);

void setPhoneNumber(string _phoneNumber);

void setAge(int _age);

// member functions

bool canVote();

};

#endif

ContactInfo.cpp:

Code as text (to copy):

#include "ContactInfo.h"

// Default constructor

ContactInfo::ContactInfo() {

name = "";

phoneNumber = "";

age = 0;

}

// Parameterised constructor

ContactInfo::ContactInfo(string _name, string _phoneNumber) {

name = _name;

phoneNumber = _phoneNumber;

age = 0;

}

// Accessor functions

// function to get name of contact

string ContactInfo::getName() {

return name;

}

// function to get phone number of contact

string ContactInfo::getPhoneNumber() {

return phoneNumber;

}

// function to get age of contact

int ContactInfo::getAge() {

return age;

}

// Mutator functions

// function to set name of contact

void ContactInfo::setName(string _name) {

name = _name;

}

// function to set phone number of contact

void ContactInfo::setPhoneNumber(string _phoneNumber) {

phoneNumber = _phoneNumber;

}

// function to set age of contact

void ContactInfo::setAge(int _age) {

age = _age;

}

// Member functions

// boolean function

// returns true if age >= 18 otherwise return false

bool ContactInfo::canVote() {

return age >= 18;

}

ContactInfoApp.cpp:

Code as text (to copy):

#include <iostream>

#include <string>

#include "ContactInfo.h"

using namespace std;

// function to display an instance of the class ContactInfo

void displayContactInfo(ContactInfo& obj) {

cout << "Name: " << obj.getName() << endl;

cout << "Phone Number: " << obj.getPhoneNumber() << endl;

cout << "Age: " << obj.getAge() << endl;

cout << "Can vote?: ";

if (obj.canVote()) cout << "Yes" << endl;

else cout << "No" << endl;

}

int main() {

// Create three instances of class ContactInfo

ContactInfo instance1("Kristen Lee", "555-2021");

instance1.setAge(45);

ContactInfo instance2, instance3;

instance2.setName("Joe Smith");

instance2.setPhoneNumber("111-9999");

instance2.setAge(5);

instance3.setName("Tom Hanks");

instance3.setPhoneNumber("111-8888");

instance3.setAge(75);

// call function to display details of three instances

displayContactInfo(instance1); cout << endl;

displayContactInfo(instance2); cout << endl;

displayContactInfo(instance3);

return 0;

}

makefile:

makefile as text (to copy):

CXX = g++

CXXFLAGS = -Wall

ContactInfoApp: ContactInfoApp.o ContactInfo.o

$(CXX) $(CXXFLAGS) -o ContactInfoApp ContactInfoApp.o ContactInfo.o

ContactInfoApp.o: ContactInfoApp.cpp

$(CXX) $(CXXFLAGS) -c ContactInfoApp.cpp

ContactInfo.o: ContactInfo.cpp ContactInfo.h

$(CXX) $(CXXFLAGS) -c ContactInfo.cpp

Sample Run:

P.s.> Check screenshots to get proper indentation of code.

ask any doubts in comments and don't forget to rate the answer.

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,...
c++ C++ CLASSES and objects DO ADD COMMENTS DISPLAY OUTPUT First make three files: episode.cpp, episode.h...
c++ C++ CLASSES and objects DO ADD COMMENTS DISPLAY OUTPUT First make three files: episode.cpp, episode.h andRun.cpp to separate class header and implementation. In this program, we are going to create a small scale Telivision Management System. A) Create a class Episode with following variables: char* episode_name, char* episode_venue, char episode_date[22] and char episode_time[18]. Input format for episode_date: dd-mm-yyyy Input format for episode_time: hh:mm am/pm B) Implement default constructor and overloaded constructor. Print “Default Constructor Called” and “Overloaded Constructor Called”...
C++ PROGRAMMING Hi! I have to make a program that adds fractions and simplifies them. I...
C++ PROGRAMMING Hi! I have to make a program that adds fractions and simplifies them. I feel like I know how to write that. What I'm having trouble with is implementing two files the professer gave us. I would appreicate any help in understanding their purpose as in if Im supposed to take information from those files or give it information. Thank you! I have attatched the homework instructions and the two files given. Implementation The main program, called calculator.cpp...
Casting class objects 1.2 Compile and execute the code listed below as it is written. Run...
Casting class objects 1.2 Compile and execute the code listed below as it is written. Run it a second time after uncommenting the line obj.speak();. public class AnimalRunner {    public static void main(String[] args)    {       Dog d1 = new Dog("Fred");       d1.speak();       Object obj = new Dog("Connie");       // obj.speak();    } } The uncommented line causes a compile error because obj is an Object reference variable and class Object doesn’t contain a speak() method. This...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance:...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance: ⦁   A base class called Pet ⦁   A mix-in class called Jumper ⦁   A Dog class and a Cat class that each inherit from Pet and jumper ⦁   Two classes that inherit from Dog: BigDog and SmallDog ⦁   One classes that inherit from Cat: HouseCat The general skeleton of the Pet, Dog, and BigDog classes will be given to you (see below, "Skeleton", but...
Need this done using PHP code and not javascript Create a PHP form with a textarea...
Need this done using PHP code and not javascript Create a PHP form with a textarea field input and a submit button. The textarea field should be able to accept up to 250 characters. When the user clicks the Submit button, read the text in the textarea and display the following results on a web age. At the bottom of the page include a link back to the form. Number of characters: Number of words: (hint: explode the string into...
Cpp Task: Create a class called Mixed. Objects of type Mixed will store and manage rational...
Cpp Task: Create a class called Mixed. Objects of type Mixed will store and manage rational numbers in a mixed number format (integer part and a fraction part). Details and Requirements Your class must allow for storage of rational numbers in a mixed number format. Remember that a mixed number consists of an integer part and a fraction part (like 3 1/2 – “three and one-half”). The Mixed class must allow for both positive and negative mixed number values. A...
C++ ONLY -- PRACTICE ASSIGNMENT For our practice assignment we have to turn in 2 files...
C++ ONLY -- PRACTICE ASSIGNMENT For our practice assignment we have to turn in 2 files - Driver.cpp and StringQueue.h Driver.cpp is provided for us, but if there are any changes needed to be made to that file please let me know. Based on the instructions below, what should the code look like for StringQueue.h ? Create a class named StringQueue in a file named StringQueue.h. Create a QueueNode structure as a private member of the class. The node should...
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions...
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions are suggested for easier procedure of making function.) void search_node(struct linked_list* list, int find_node_ value) (The function to make) This function finds the node from the list that value is same with find_node_value and count the order of the node. This function should print message “The order of (node_value) is (order).” and error message “Function search_node : There is no such node to search.”....
My assignment: Triplet Template Class Directions: Define a template class for a generic triplet. The private...
My assignment: Triplet Template Class Directions: Define a template class for a generic triplet. The private data member for the triplet is a generic array with three elements. The triplet ADT has the following functions:  default constructor  explicit constructor: initialize the data member using parameters  three accessors (three get functions) which will return the value of each individual element of the array data member  one mutator (set function) which will assign values to the data member...