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,...
Part 1 - LIST Create an unsorted LIST class ( You should already have this code...
Part 1 - LIST Create an unsorted LIST class ( You should already have this code from a prior assignment ). Each list should be able to store 100 names. Part 2 - Create a Class ArrayListClass It will contain an array of 27 "list" classes. Next, create a Class in which is composed a array of 27 list classes. Ignore index 0... Indexes 1...26 correspond to the first letter of a Last name. Again - ignore index 0. index...
You can complete this assignment individually or as a group of two people. In this assignment...
You can complete this assignment individually or as a group of two people. In this assignment you will create a ​​Sorted Singly-Linked List​ that performs basic list operations using C++. This linked list should not allow duplicate elements. Elements of the list should be of type ‘ItemType’. ‘ItemType’ class should have a private integer variable with the name ‘value’. Elements in the linked list should be sorted in the ascending order according to this ‘value’ variable. You should create a...
Lab 2 Write a C program that runs on ocelot for a mini calculator using only...
Lab 2 Write a C program that runs on ocelot for a mini calculator using only the command line options. You must use getopt to parse the command line. The calculator will only do addition, subtraction, multiplication, division, and a power of 2. Usage: minicalc [-a num] [-d num] [-m num] [-s num] [-x] value • The variable value is the starting value. • Value should be validated to be an integer between 1 and 50 inclusive. Error message and...
Below is the problem that I have and here is the code that I have in...
Below is the problem that I have and here is the code that I have in c++. Can someone help me on what I am doing wrong or the correct code. A teacher has asked all her students to line up according to their first name. For example, in one class Amy will be at the front of the line, and Yolanda will be at the end. Write a program that prompts the user to enter the number of students...
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...
ARM on a raspberry pi 1. Create a assembly program that branches based off the value...
ARM on a raspberry pi 1. Create a assembly program that branches based off the value of three different variables. ## Details Task 1: I highly suggest reading the book and doing the practice before doing this. Name your file cp5.s. You need to initally start with the three variables. * the variables should be called max, t1, t2. * Set the values to whatever you would like. * max tells us the cut off for a value * if...
All the code below is in the file CatFish.java. Complete the classes below. Keep it very...
All the code below is in the file CatFish.java. Complete the classes below. Keep it very simple. The code you write must produce the output shown at the bottom of the page. Read the whole problem first - how you follow later instructions may affect early choices. Assume you have any import atatements you need. You may not need all blank lines. interface Movers{ public void move(); //this method will print (see output below) } class Cat _____________________________{ _____________________________________ _____________________________________...
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...