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

Implement the class code.h that work with the provided testCode.cpp // // testCo

ID: 3905647 • Letter: I

Question

Implement the class code.h that work with the provided testCode.cpp

//

// testCode.cpp

//

// test the Code predicate

#include "Facility.h"

#include "Code.h"

#include <iostream>

#include <fstream>

#include <iomanip>

#include <string>

using namespace std;

int main(int argc, char **argv)

{

ifstream facilities_file("testFacility1.in");

string line;

getline(facilities_file,line);

Facility *f = new Facility(line);

cout << f->code() << " " << f->name() << endl;

cout << "test if DFW: " << boolalpha << Code("DFW ")(f) << endl;

cout << "test if SFO: " << boolalpha << Code("SFO ")(f) << endl;

delete f;

}

//

// Facility.h

//

#ifndef FACILITY_H

#define FACILITY_H

#include<string>

class Facility

{

public:

Facility(std::string s);

std::string site_number(void) const;

std::string type(void) const;

std::string code(void) const;

std::string name(void) const;

double latitude(void) const;

double longitude(void) const;

double distance(double lat, double lon) const;

private:

const std::string site_number_;

const std::string type_;

const std::string code_;

const std::string name_;

const double latitude_, longitude_;

double convert_latitude(std::string s) const;

double convert_longitude(std::string s) const;

};

#endif

Explanation / Answer

Code.h header file

Header file contains constructor which used to initilize variables.

The string we pass through Code in "cout" of main and boolalpha are initialized in code.h .

#ifndef CODE_H

#define CODE_H

#include<string>

#include <iostream>


class Code {
public:

bool boolalpha;

   Code(string s)

   {

    this.s = s;

    boolalpha = true;

}


};
#endif