SlideShare a Scribd company logo
1 of 8
C++
C++
C++
In Chapter 1, the class clockType was designed to implement the time of day in a program.
Certain applications, in addition to hours, minutes, and seconds, might require you to store the
time zone. By using the files provided (clockType.h and clockTypeImp.cpp), derive the class
extClockType from the class clockType by adding a member variable to store the time zone.
Override a member function printTime and add constructors to make the derived class
functional. Finally, test your program by setting the time to 5: 10: 15 (CST) and output it on the
console.
Submit a header file consisting of the derived class declaration, a cpp file which include member
function definitions of the derived class, and another cpp file which includes the main function.
Copy and paste the screenshot of the output here.
//----------------------------------------------------------------------------------------------------
//clockType.h, the specification file for the class clockType
#ifndef H_ClockType
#define H_ClockType
class clockType
{
public:
void setTime(int hours, int minutes, int seconds);
//Function to set the time.
//The time is set according to the parameters.
//Postcondition: hr = hours; min = minutes;
// sec = seconds
// The function checks whether the values of
// hours, minutes, and seconds are valid. If a
// value is invalid, the default value 0 is
// assigned.
void getTime(int& hours, int& minutes, int& seconds) const;
//Function to return the time.
//Postcondition: hours = hr; minutes = min;
// seconds = sec
void printTime() const;
//Function to print the time.
//Postcondition: The time is printed in the form
// hh:mm:ss.
void incrementSeconds();
//Function to increment the time by one second.
//Postcondition: The time is incremented by one
// second.
// If the before-increment time is 23:59:59, the
// time is reset to 00:00:00.
void incrementMinutes();
//Function to increment the time by one minute.
//Postcondition: The time is incremented by one
// minute.
// If the before-increment time is 23:59:53,
// the time is reset to 00:00:53.
void incrementHours();
//Function to increment the time by one hour.
//Postcondition: The time is incremented by one
// hour.
// If the before-increment time is 23:45:53, the
// time is reset to 00:45:53.
bool equalTime(const clockType& otherClock) const;
//Function to compare the two times.
//Postcondition: Returns true if this time is
// equal to otherClock; otherwise,
// returns false.
clockType(int hours, int minutes, int seconds);
//constructor with parameters
//The time is set according to the parameters.
//Postcondition: hr = hours; min = minutes;
// sec = seconds
// The constructor checks whether the values of
// hours, minutes, and seconds are valid. If a
// value is invalid, the default value 0 is
// assigned.
clockType();
//default constructor with parameters
//The time is set to 00:00:00.
//Postcondition: hr = 0; min = 0; sec = 0
private:
int hr; //variable to store the hours
int min; //variable to store the minutes
int sec; //variable to store the seconds
};
#endif
//-----------------------------------------------------------------------------------------------
//Implementation File for the class clockType
#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::incrementHours()
{
hr++;
if (hr > 23)
hr = 0;
}
void clockType::incrementMinutes()
{
min++;
if (min > 59)
{
min = 0;
incrementHours();
}
}
void clockType::incrementSeconds()
{
sec++;
if (sec > 59)
{
sec = 0;
incrementMinutes();
}
}
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;
}
bool clockType::equalTime(const clockType& otherClock) const
{
return (hr == otherClock.hr
&& min == otherClock.min
&& sec == otherClock.sec);
}
clockType::clockType(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;
}
clockType::clockType() //default constructor
{
hr = 0;
min = 0;
sec = 0;
}

More Related Content

Similar to C++ C++ C++ In Chapter 1- the class clockType was designed to implem.docx

Orangescrum Time Log Gold add-on User Manual
Orangescrum Time Log Gold add-on User Manual Orangescrum Time Log Gold add-on User Manual
Orangescrum Time Log Gold add-on User Manual Orangescrum
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfjaipur2
 
How to add system calls to OS/161
How to add system calls to OS/161How to add system calls to OS/161
How to add system calls to OS/161Xiao Qin
 
Please I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdfPlease I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdfankit11134
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104swena_gupta
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104swena_gupta
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104swena_gupta
 
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docxkatherncarlyle
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of ChainerKenta Oono
 
Scheduling tasks the human way - Brad Wood - ITB2021
Scheduling tasks the human way -  Brad Wood - ITB2021Scheduling tasks the human way -  Brad Wood - ITB2021
Scheduling tasks the human way - Brad Wood - ITB2021Ortus Solutions, Corp
 
Cpu performance matrix
Cpu performance matrixCpu performance matrix
Cpu performance matrixRehman baig
 
Csphtp1 08
Csphtp1 08Csphtp1 08
Csphtp1 08HUST
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptxDiptoRoy21
 
Classes and data abstraction
Classes and data abstractionClasses and data abstraction
Classes and data abstractionHoang Nguyen
 
Chapter20 class-example-program
Chapter20 class-example-programChapter20 class-example-program
Chapter20 class-example-programDeepak Singh
 
L07_performance and cost in advanced hardware- computer architecture.pptx
L07_performance and cost in advanced hardware- computer architecture.pptxL07_performance and cost in advanced hardware- computer architecture.pptx
L07_performance and cost in advanced hardware- computer architecture.pptxIsaac383415
 
Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Dmitry Ponomarenko
 
Processes And Job Control
Processes And Job ControlProcesses And Job Control
Processes And Job Controlahmad bassiouny
 

Similar to C++ C++ C++ In Chapter 1- the class clockType was designed to implem.docx (20)

Orangescrum Time Log Gold add-on User Manual
Orangescrum Time Log Gold add-on User Manual Orangescrum Time Log Gold add-on User Manual
Orangescrum Time Log Gold add-on User Manual
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdf
 
How to add system calls to OS/161
How to add system calls to OS/161How to add system calls to OS/161
How to add system calls to OS/161
 
Please I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdfPlease I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdf
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of Chainer
 
Scheduling tasks the human way - Brad Wood - ITB2021
Scheduling tasks the human way -  Brad Wood - ITB2021Scheduling tasks the human way -  Brad Wood - ITB2021
Scheduling tasks the human way - Brad Wood - ITB2021
 
Cpu performance matrix
Cpu performance matrixCpu performance matrix
Cpu performance matrix
 
Csphtp1 08
Csphtp1 08Csphtp1 08
Csphtp1 08
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
 
Classes and data abstraction
Classes and data abstractionClasses and data abstraction
Classes and data abstraction
 
C chap16
C chap16C chap16
C chap16
 
Chapter20 class-example-program
Chapter20 class-example-programChapter20 class-example-program
Chapter20 class-example-program
 
C++ L08-Classes Part1
C++ L08-Classes Part1C++ L08-Classes Part1
C++ L08-Classes Part1
 
L07_performance and cost in advanced hardware- computer architecture.pptx
L07_performance and cost in advanced hardware- computer architecture.pptxL07_performance and cost in advanced hardware- computer architecture.pptx
L07_performance and cost in advanced hardware- computer architecture.pptx
 
Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)
 
Processes And Job Control
Processes And Job ControlProcesses And Job Control
Processes And Job Control
 

More from CharlesCSZWhitei

Canada has a National Health Plan- which means there is one health pla.docx
Canada has a National Health Plan- which means there is one health pla.docxCanada has a National Health Plan- which means there is one health pla.docx
Canada has a National Health Plan- which means there is one health pla.docxCharlesCSZWhitei
 
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docxCan you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docxCharlesCSZWhitei
 
Can you help me in to flat this without recursion i-e simple loops- d.docx
Can you help me in to flat this without recursion i-e simple loops-  d.docxCan you help me in to flat this without recursion i-e simple loops-  d.docx
Can you help me in to flat this without recursion i-e simple loops- d.docxCharlesCSZWhitei
 
Can you explain if there would be any variations in the correlation be.docx
Can you explain if there would be any variations in the correlation be.docxCan you explain if there would be any variations in the correlation be.docx
Can you explain if there would be any variations in the correlation be.docxCharlesCSZWhitei
 
Can you draw it so it's easy to understand- Minimize the following DFA.docx
Can you draw it so it's easy to understand- Minimize the following DFA.docxCan you draw it so it's easy to understand- Minimize the following DFA.docx
Can you draw it so it's easy to understand- Minimize the following DFA.docxCharlesCSZWhitei
 
Can you answer the substeps 1 through 8 Study the following image and.docx
Can you answer the substeps 1 through 8 Study the following image and.docxCan you answer the substeps 1 through 8 Study the following image and.docx
Can you answer the substeps 1 through 8 Study the following image and.docxCharlesCSZWhitei
 
can someone write out the steps- Clonex Labs- Incorporated- uses the.docx
can someone write out the steps-  Clonex Labs- Incorporated- uses the.docxcan someone write out the steps-  Clonex Labs- Incorporated- uses the.docx
can someone write out the steps- Clonex Labs- Incorporated- uses the.docxCharlesCSZWhitei
 
can someone please create the pictorial desigj Team Assignment Susans.docx
can someone please create the pictorial desigj  Team Assignment Susans.docxcan someone please create the pictorial desigj  Team Assignment Susans.docx
can someone please create the pictorial desigj Team Assignment Susans.docxCharlesCSZWhitei
 
Can someone help with this- Attached is all the information- Thank you.docx
Can someone help with this- Attached is all the information- Thank you.docxCan someone help with this- Attached is all the information- Thank you.docx
Can someone help with this- Attached is all the information- Thank you.docxCharlesCSZWhitei
 
c) OB is for evervone- Build an argument to support this statement-.docx
c) OB is for evervone- Build an argument to support this statement-.docxc) OB is for evervone- Build an argument to support this statement-.docx
c) OB is for evervone- Build an argument to support this statement-.docxCharlesCSZWhitei
 
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docxc++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docxCharlesCSZWhitei
 
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docxc++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docxCharlesCSZWhitei
 
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docxBy joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docxCharlesCSZWhitei
 
caldelsta the rebobiety of the folbowing x x x.docx
caldelsta the rebobiety of the folbowing x x x.docxcaldelsta the rebobiety of the folbowing x x x.docx
caldelsta the rebobiety of the folbowing x x x.docxCharlesCSZWhitei
 
Calculate the payout ratio- earnings per share- and return on common s.docx
Calculate the payout ratio- earnings per share- and return on common s.docxCalculate the payout ratio- earnings per share- and return on common s.docx
Calculate the payout ratio- earnings per share- and return on common s.docxCharlesCSZWhitei
 
Calculate the genotypes and genotypic proportions of a cross between A.docx
Calculate the genotypes and genotypic proportions of a cross between A.docxCalculate the genotypes and genotypic proportions of a cross between A.docx
Calculate the genotypes and genotypic proportions of a cross between A.docxCharlesCSZWhitei
 
Business Philosophy- What is important to you in business- How will y.docx
Business Philosophy- What is important to you in business-  How will y.docxBusiness Philosophy- What is important to you in business-  How will y.docx
Business Philosophy- What is important to you in business- How will y.docxCharlesCSZWhitei
 
Calculate the CFFA- Balance Sheet $150-000 20142015 20142015Cas.docx
Calculate the CFFA-     Balance Sheet $150-000    20142015 20142015Cas.docxCalculate the CFFA-     Balance Sheet $150-000    20142015 20142015Cas.docx
Calculate the CFFA- Balance Sheet $150-000 20142015 20142015Cas.docxCharlesCSZWhitei
 
Cabell Products is a division of a major corporation- Last year the di.docx
Cabell Products is a division of a major corporation- Last year the di.docxCabell Products is a division of a major corporation- Last year the di.docx
Cabell Products is a division of a major corporation- Last year the di.docxCharlesCSZWhitei
 
Business Ethics and White-Collar Crime Business Ethics There are many (2).docx
Business Ethics and White-Collar Crime Business Ethics There are many (2).docxBusiness Ethics and White-Collar Crime Business Ethics There are many (2).docx
Business Ethics and White-Collar Crime Business Ethics There are many (2).docxCharlesCSZWhitei
 

More from CharlesCSZWhitei (20)

Canada has a National Health Plan- which means there is one health pla.docx
Canada has a National Health Plan- which means there is one health pla.docxCanada has a National Health Plan- which means there is one health pla.docx
Canada has a National Health Plan- which means there is one health pla.docx
 
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docxCan you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
 
Can you help me in to flat this without recursion i-e simple loops- d.docx
Can you help me in to flat this without recursion i-e simple loops-  d.docxCan you help me in to flat this without recursion i-e simple loops-  d.docx
Can you help me in to flat this without recursion i-e simple loops- d.docx
 
Can you explain if there would be any variations in the correlation be.docx
Can you explain if there would be any variations in the correlation be.docxCan you explain if there would be any variations in the correlation be.docx
Can you explain if there would be any variations in the correlation be.docx
 
Can you draw it so it's easy to understand- Minimize the following DFA.docx
Can you draw it so it's easy to understand- Minimize the following DFA.docxCan you draw it so it's easy to understand- Minimize the following DFA.docx
Can you draw it so it's easy to understand- Minimize the following DFA.docx
 
Can you answer the substeps 1 through 8 Study the following image and.docx
Can you answer the substeps 1 through 8 Study the following image and.docxCan you answer the substeps 1 through 8 Study the following image and.docx
Can you answer the substeps 1 through 8 Study the following image and.docx
 
can someone write out the steps- Clonex Labs- Incorporated- uses the.docx
can someone write out the steps-  Clonex Labs- Incorporated- uses the.docxcan someone write out the steps-  Clonex Labs- Incorporated- uses the.docx
can someone write out the steps- Clonex Labs- Incorporated- uses the.docx
 
can someone please create the pictorial desigj Team Assignment Susans.docx
can someone please create the pictorial desigj  Team Assignment Susans.docxcan someone please create the pictorial desigj  Team Assignment Susans.docx
can someone please create the pictorial desigj Team Assignment Susans.docx
 
Can someone help with this- Attached is all the information- Thank you.docx
Can someone help with this- Attached is all the information- Thank you.docxCan someone help with this- Attached is all the information- Thank you.docx
Can someone help with this- Attached is all the information- Thank you.docx
 
c) OB is for evervone- Build an argument to support this statement-.docx
c) OB is for evervone- Build an argument to support this statement-.docxc) OB is for evervone- Build an argument to support this statement-.docx
c) OB is for evervone- Build an argument to support this statement-.docx
 
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docxc++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
 
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docxc++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
 
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docxBy joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
 
caldelsta the rebobiety of the folbowing x x x.docx
caldelsta the rebobiety of the folbowing x x x.docxcaldelsta the rebobiety of the folbowing x x x.docx
caldelsta the rebobiety of the folbowing x x x.docx
 
Calculate the payout ratio- earnings per share- and return on common s.docx
Calculate the payout ratio- earnings per share- and return on common s.docxCalculate the payout ratio- earnings per share- and return on common s.docx
Calculate the payout ratio- earnings per share- and return on common s.docx
 
Calculate the genotypes and genotypic proportions of a cross between A.docx
Calculate the genotypes and genotypic proportions of a cross between A.docxCalculate the genotypes and genotypic proportions of a cross between A.docx
Calculate the genotypes and genotypic proportions of a cross between A.docx
 
Business Philosophy- What is important to you in business- How will y.docx
Business Philosophy- What is important to you in business-  How will y.docxBusiness Philosophy- What is important to you in business-  How will y.docx
Business Philosophy- What is important to you in business- How will y.docx
 
Calculate the CFFA- Balance Sheet $150-000 20142015 20142015Cas.docx
Calculate the CFFA-     Balance Sheet $150-000    20142015 20142015Cas.docxCalculate the CFFA-     Balance Sheet $150-000    20142015 20142015Cas.docx
Calculate the CFFA- Balance Sheet $150-000 20142015 20142015Cas.docx
 
Cabell Products is a division of a major corporation- Last year the di.docx
Cabell Products is a division of a major corporation- Last year the di.docxCabell Products is a division of a major corporation- Last year the di.docx
Cabell Products is a division of a major corporation- Last year the di.docx
 
Business Ethics and White-Collar Crime Business Ethics There are many (2).docx
Business Ethics and White-Collar Crime Business Ethics There are many (2).docxBusiness Ethics and White-Collar Crime Business Ethics There are many (2).docx
Business Ethics and White-Collar Crime Business Ethics There are many (2).docx
 

Recently uploaded

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 

Recently uploaded (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

C++ C++ C++ In Chapter 1- the class clockType was designed to implem.docx

  • 1. C++ C++ C++ In Chapter 1, the class clockType was designed to implement the time of day in a program. Certain applications, in addition to hours, minutes, and seconds, might require you to store the time zone. By using the files provided (clockType.h and clockTypeImp.cpp), derive the class extClockType from the class clockType by adding a member variable to store the time zone. Override a member function printTime and add constructors to make the derived class functional. Finally, test your program by setting the time to 5: 10: 15 (CST) and output it on the console. Submit a header file consisting of the derived class declaration, a cpp file which include member function definitions of the derived class, and another cpp file which includes the main function. Copy and paste the screenshot of the output here. //---------------------------------------------------------------------------------------------------- //clockType.h, the specification file for the class clockType #ifndef H_ClockType #define H_ClockType class clockType { public: void setTime(int hours, int minutes, int seconds); //Function to set the time. //The time is set according to the parameters. //Postcondition: hr = hours; min = minutes; // sec = seconds // The function checks whether the values of // hours, minutes, and seconds are valid. If a
  • 2. // value is invalid, the default value 0 is // assigned. void getTime(int& hours, int& minutes, int& seconds) const; //Function to return the time. //Postcondition: hours = hr; minutes = min; // seconds = sec void printTime() const; //Function to print the time. //Postcondition: The time is printed in the form // hh:mm:ss. void incrementSeconds(); //Function to increment the time by one second. //Postcondition: The time is incremented by one // second. // If the before-increment time is 23:59:59, the // time is reset to 00:00:00. void incrementMinutes(); //Function to increment the time by one minute. //Postcondition: The time is incremented by one // minute. // If the before-increment time is 23:59:53, // the time is reset to 00:00:53. void incrementHours();
  • 3. //Function to increment the time by one hour. //Postcondition: The time is incremented by one // hour. // If the before-increment time is 23:45:53, the // time is reset to 00:45:53. bool equalTime(const clockType& otherClock) const; //Function to compare the two times. //Postcondition: Returns true if this time is // equal to otherClock; otherwise, // returns false. clockType(int hours, int minutes, int seconds); //constructor with parameters //The time is set according to the parameters. //Postcondition: hr = hours; min = minutes; // sec = seconds // The constructor checks whether the values of // hours, minutes, and seconds are valid. If a // value is invalid, the default value 0 is // assigned. clockType(); //default constructor with parameters //The time is set to 00:00:00. //Postcondition: hr = 0; min = 0; sec = 0
  • 4. private: int hr; //variable to store the hours int min; //variable to store the minutes int sec; //variable to store the seconds }; #endif //----------------------------------------------------------------------------------------------- //Implementation File for the class clockType #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;
  • 5. else sec = 0; } void clockType::getTime(int& hours, int& minutes, int& seconds) const { hours = hr; minutes = min; seconds = sec; } void clockType::incrementHours() { hr++; if (hr > 23) hr = 0; } void clockType::incrementMinutes() { min++; if (min > 59) { min = 0; incrementHours();
  • 6. } } void clockType::incrementSeconds() { sec++; if (sec > 59) { sec = 0; incrementMinutes(); } } 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; }
  • 7. bool clockType::equalTime(const clockType& otherClock) const { return (hr == otherClock.hr && min == otherClock.min && sec == otherClock.sec); } clockType::clockType(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; } clockType::clockType() //default constructor {
  • 8. hr = 0; min = 0; sec = 0; }