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

1. Write a specification file for the Period class that has a private field that

ID: 3623442 • Letter: 1

Question

1. Write a specification file for the Period class that has a private field that is an
enumeration type, representing the names of the periods. It should have functions
that :
o return the period as a string, and
o increment the period to the next most recent period (if the period is already
QUATERNARY, the increment operation should do nothing).
It should have a default constructor that sets the period to PRECAMBRIAN, and a
constructor with a parameter of the enumeration type to allow the user to create a Period
object containing any period.
The table of the entire periods is listed below:
Period Time Starting Date (millions of years)
Quaternary 2.5
Tertiary 65
Cretaceous 136
Jurassic 192
Triassic 225
Permian 280
Carboniferous 345
Devonian 395
Silurian 435
Ordovician 500
Cambrian 570
Precambrian 4500 or earlier
2. Write the complete implementation file of Period class.

Explanation / Answer

please rate - thanks

I don't understant the need for the starting date.

#include <iostream>
using namespace std;
enum periodName
{PRECAMBRIAN,CAMBRIAN,ORDOVICIAN,SILURIAN,DEVONIAN,CARBONIFEROUS,PERMIAN,
TRIASSIC,JURASSIC,CRETACEOUS,TERTIARY,QUATERNARY};
class Period
{
periodName name;
public:
Period()
{name = PRECAMBRIAN;
}
Period(periodName n)
{name = n;
}
string getName()
{string period[]={"Precambrian","Cambrian","Ordovician","Silurian","Devonian",
                    "Carboniferous","Permian","Triassic","Jurassic",
                    "Cretaceous","Tertiary","Quaternary"};
return period[name];
}


void increment()
{
if(name!=QUATERNARY)
name=(periodName)(name + 1);
}
};

int main()
{
Period p1;
Period p2(QUATERNARY);
Period p3(JURASSIC);
cout<<"Period 1 before increment: "<<p1.getName()<<endl;
p1.increment();
cout<<"Period 1 after increment: "<<p1.getName()<<endl;
cout<<"Period 2 before increment: "<<p2.getName()<<endl;
p2.increment();
cout<<"Period 2 after increment: "<<p2.getName()<<endl;
cout<<"Period 3 before increment: "<<p3.getName()<<endl;
p3.increment();
cout<<"Period 3 after increment: "<<p3.getName()<<endl;

system("pause");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote