#include <iostream>
#include <fstream>
#include "PhoneCall.h"
using namespace std;
PhoneCall::PhoneCall() { //default constructor
number = " ";
length = 0;
rate = 0;
}
PhoneCall::PhoneCall(string new_number) { //overloaded constructor
number = new_number;
length = 0;
rate = 0;
}
PhoneCall::~PhoneCall() { //destructor
;
}
string PhoneCall::get_number() const {
return number;
}
int PhoneCall::get_length() const {
return length;
}
float PhoneCall::get_rate() const {
return rate;
}
float PhoneCall::calcCharge() { ///datermine cost of call
return length * rate;
}
bool operator==(const PhoneCall& call1, const PhoneCall& call2) {
return(call1.number == call2.number);
}
istream& operator >> (istream& ins, PhoneCall& the_call) {
ins >> the_call.number >> the_call.length >> the_call.rate;
return ins;
}
ostream& operator << (ostream& outs, const PhoneCall& the_call) {
outs << the_call.number << endl << the_call.length << endl << the_call.rate;
return outs;
}
#pragma once
#ifndef PHONECALL_H
#define PHONECALL_H
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std;
class PhoneCall {
public:
//the difference between the overloaded friend functions for the stream extraction operator >> and the stream insertion
//operation. The overloaded stream insertion operator << uses the const keyword to ensure that the object which is
//sent to the output stream will not be modified. In the case of the overloaded stream extraction operator >>,
//the object retrieved from the input stream, must change. The overloaded stream insertion operator << modifies the
//output stream and the overloaded stream extraction operator >> modifies the input stream, therefore both the
//ostream and the istream must be reference parameters
friend istream& operator >> (istream& ins, PhoneCall& the_call);
friend ostream& operator << (ostream& outs, const PhoneCall& the_call);
//the const keyword is used to guaratee that this function will not modify the PhoneCall objects.
//When we compared two PhoneCall objects with ==, we do not want to change or modify the objects we
//compare. A friend function may manipulate the underlying structure of the class but the const
//keyword ensures that these manipulations do not modify the object in any possible way
friend bool operator == (const PhoneCall& call1, const PhoneCall& call2);
PhoneCall(); //default constructor
PhoneCall(string new_number); //overloaded constructor
~PhoneCall(); //destructor
string get_number() const; //accessor
int get_length() const; //accessor
float get_rate() const; //accessor
float calcCharge(); //calculate amount charged for this call
private:
string number; //member variables
int length;
float rate;
};
#endif PHONECALL_H
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}