Question: Modify the following C++ code to define a class Contact which has three integer parts, for Example: Part1: 330, Part2: 244, Part3: 3424. You will
Modify the following C++ code to define a class Contact which has three integer parts, for Example: Part1: 330, Part2: 244, Part3: 3424. You will define the Loan ADT class in separate files. You will have 3 additional files, Bank.cpp, Contact.cpp, and Contact.h files since you have to define the Bank ADT and the Contact ADT. Recreate the driver that demonstrates the use of the classes used. Write a makefile to compile this program with the make command.
Add the pre- and post- conditions to all source code. Also include the test cases in the driver.
//Main driver #include #include "Loan.h" using namespace loanClass; int main() { Loan loan1(ID(111, 22, 4444), 2300, 5.5, 48); // initialize to values given Loan loan2; std::cout << "Display loan1 "; loan1.display(); loan2.set(); // set the values std::cout << "Display loan2 "; loan2.display(); return 0; } // File ID.cpp #include #include "ID.h" using namespace loanID; ID::ID() { // use default values } ID::ID(int l, int m, int r) { left = l; middle = m; right = r; } void ID::display() { std::cout << right << "-" << middle << "-" << right << std::endl; } //loan.cpp #include #include "Loan.h" #include "ID.h" using namespace loanClass; Loan::Loan() { } Loan::Loan(Bank bank, ID I, float am, float rt, int trm) { id = I; amount = am; rate = rt; term = trm; } void Loan::set() { int l, m, r; ID temp_id; // Initialize the loan1 object std::cout << "Enter the left part of the loan ID "; std::cin >> l; std::cout << "Enter the middle part of the loan ID "; std::cin >> m; std::cout << "Enter the right part of the loan ID "; std::cin >> r; id = ID(l, m, r); std::cout << "Enter the amount of this loan "; std::cin >> amount; std::cout << "Enter the annual interest rate of this loan (in %) "; std::cin >> rate; std::cout << "Enter the term (number of months, length of the loan) "; std::cin >> term; } void Loan::display() { id.display(); std::cout << amount << std::endl; std::cout << rate << std::endl; std::cout << term << std::endl; } // File ID.h #ifndef ID_H #define ID_H #include namespace loanID { class ID { public: ID(); ID(int, int, int); void display(); private: int left; int middle; int right; }; } // end of idclass1 namespace #endif //loan.h file #ifndef LOAN_H #define LOAN_H #include #include "Bank.h" namespace loanClass { class ID { public: ID(); ID(int, int, int); void display(); private: int left; int middle; int right; }; class Loan // Loan class definition { public: Loan(); Loan(Bank bank, ID id, float amount, float rate, int term); void set(); float payment(); void display(); private: Bank bank; ID id; // assume an unique integer in three integer parts float amount; // $ amount of the loan float rate; // annual interest rate int term; // number of months, length of the loan }; } #endif //file bank.h #ifndef BANK_H #define BANK_H #include #include "Loan.h" // This will go to Bank.h file class Bank // Bank class definition { public: Bank(); Bank(int bank_ID, CONTACT phone, CONTACT fax); private: int bank_ID; // 4 digit integer Contact phone; // object three integer pieces, # # #, # # #, # # # # Contact fax; // object three integer pieces, # # #, # # #, # # # # }; #endif