Need help with comparing and incrementing values

-Create two clockType objects: cellPhoneClock and myComputerClock.
-Prompt the user to enter the times for both clocks.
-Display both times with appropriate documentation.
-If the clocks do not have equal times, set myComputerClock to the cellPhoneClock time.
-Set myComputerClock so that it is 1 hour, 5 minutes, 23 seconds faster than the cellPhoneClock.
-Display both times again, with appropriate documentation.

I am needing help starting with the step where it says that if the clocks arent equal to set them equal to each other.

testclockType.cpp file

#include <iostream>
#include<string>
#include "clockType.h"
using namespace std;


int main()
{
//Variables for cell phone clock
int phrs;
int pmins;
int psecs;
//Variables for computer clock
int chrs;
int cmins;
int csecs;

cout << " Welcome! \n" ;
cout << " Set your clock \n" ;

clockType cellPhoneClock;
clockType myComputerClock;

cout << " Enter the time for your cell phone clock: \n";
cout << " Hours: ";
cin >> phrs;
cout << " Minutes: ";
cin >> pmins;
cout << " Seconds: ";
cin >> psecs;
cellPhoneClock.setTime(phrs,pmins,psecs);
cout << endl << endl;
cout << " Enter the time for your computer clock: \n";
cout << " Hours: ";
cin >> chrs;
cout << " Minutes: ";
cin >> cmins;
cout << " Seconds: ";
cin >> csecs;
myComputerClock.setTime(chrs,cmins,csecs);
cout << endl << endl;

cout << " Cellphone : ";

cellPhoneClock.printTime();
cout << endl << endl;
cout << " Computer : ";
myComputerClock.printTime();
cout << endl << endl;

if (phrs != chrs && pmins != cmins && psecs != csecs)
{
myComputerClock.equalTime(cellPhoneClock);
cout << "The original time was : \n";
cout << "Cell Phone : " << cellPhoneClock.printTime();
cout << endl << endl;
cout << "Computer : " << myComputerClock.printTime();
cout << endl << endl;
cout << "The time now is : \n";
cout << "Cellphone : " <<
}
else
{
myComputerClock.incrementHours();
myComputerClock.incrementMinutes();
myComputerClock.incrementSeconds();
}


return 0;
}

clockType.h file

#ifndef CLOCKTYPE_H
#define CLOCKTYPE_H


using namespace std;

class clockType
{
public:

void setTime (int hours, int minutes, int seconds);


void getTime (int& hours, int& minutes, int& seconds) const;


void printTime() const;


void incrementHours();


void incrementMinutes();


void incrementSeconds();


bool equalTime(const clockType& otherClock) const;

clockType(int hours, int minutes, int seconds);

clockType();



private:
int hr; //stores the hours
int min; //stores the minutes
int sec; //stores the seconds
};
#endif

testclockTypeImp.cpp file

#include<iostream>
#include "clockType.h"


using namespace std;

void clockType::setTime (int hours, int minutes, int seconds)
{
if (0 <= hours && hours < 24)
hr = hours;
else
hr = 0;

if (0 <= minutes && minutes < 60)
min = minutes;
else
min = 0;

if (0 <= seconds && seconds < 60)
sec = seconds;
else
sec = 0;
}

void clockType::getTime (int& hours, int& minutes, int& seconds) const
{
hours=hr;
minutes=min;
seconds=sec;
}

void clockType::printTime() const
{
if (hr < 10)
cout << "0";
cout << hr << ":";

if (min < 10)
cout << "0";
cout << min << ":";

if (sec < 10)
cout << "0";
cout << sec;

}

void clockType::incrementHours()
{
hr++;
if (hr > 23)
hr=0;
}

void clockType::incrementMinutes()
{
min++;
if (min > 59)
{
min = 0;
incrementHours(); //incrementHours
}
}

void clockType::incrementSeconds()
{
sec++;

if (sec > 59)
{
sec = 0;
incrementMinutes(); //incrementMinutes
}
}

bool clockType::equalTime(const clockType& otherClock) const
{
return (hr == otherClock.hr
&& min == otherClock.min
&& sec == otherClock.sec);
}

//Constructor without parameters
clockType::clockType()
{
hr = 0;
min = 0;
sec = 0;
}

//Constructor with parameters
clockType::clockType(int hours, int minutes, int seconds)
{
if (0 <= hours && hours < 24)
hr = hours;
else
hr = hours;
if (0 <= minutes && minutes < 60)
min = minutes;
else
min = 0;
if (0 <= seconds && seconds <60)
sec = seconds;
else
sec = 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef CLOCKTYPE_H
#define CLOCKTYPE_H


using namespace std;

class clockType
{
public:

	void setTime (int hours, int minutes, int seconds);


	void getTime (int& hours, int& minutes, int& seconds) const;


	void printTime() const;


	void incrementHours();


	void incrementMinutes();


	void incrementSeconds();


	bool equalTime(const clockType& otherClock) const; 
	
	clockType(int hours, int minutes, int seconds);
	
	clockType();
	

		
private: 
      int hr;    //stores the hours 
	  int min;   //stores the minutes 
	  int sec;   //stores the seconds
}; 
#endif







Right now I am getting an error

1
2
testclockType.cpp: In function âint main()â:
testclockType.cpp:80: error: no match for âoperator<<â in âstd::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(& std::cout)), ((const char*)"Cell Phone : ")) << cellPhoneClock.clockType::printTime()â


It's where I try to display the cell phone time. Not sure why it is not working

1
2
3
4
5
6
7
8
9
10
11
if (phrs != chrs && pmins != cmins && psecs != csecs)
	{
		myComputerClock.equalTime(cellPhoneClock);
		cout << "The original time was : \n";
		cout << "Cell Phone : " << cellPhoneClock.printTime();
		/*cout << endl << endl;
		cout << "Computer   : " << myComputerClock.printTime();
		cout << endl << endl;
		cout << "The time now is : \n";
		//cout << "Cellphone  : " << cellPhoneClock.equalTime();*/
	}
It worked! Thank you.
But now I am receiving these errors:

1
2
3
testclockType.cpp: In function âint main()â:
testclockType.cpp:88: error: no matching function for call to âclockType::equalTime()â
clockType.h:36: note: candidates are: bool clockType::equalTime(const clockType&) const



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if (phrs != chrs && pmins != cmins && psecs != csecs)
	{
		myComputerClock.equalTime(cellPhoneClock);
		cout << "The original time was : \n";
		cout << "Cell Phone : "; 
	    cellPhoneClock.printTime();
		cout << endl << endl;
		cout << "Computer   : " ;
		myComputerClock.printTime();
		cout << endl << endl;
		cout << "The time now is : \n";
		cout << "Cellphone  : "; 
		cellPhoneClock.equalTime();
	}
	else 
	{
		myComputerClock.incrementHours();
		myComputerClock.incrementMinutes();
		myComputerClock.incrementSeconds();
	}
1
2
clockType cellPhoneClock;
clockType myComputerClock;
Topic archived. No new replies allowed.