Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Deliverable 3 : In this third deliverable, you are going to be using the Standard Template Library Data Structures. vector, stack, queue, forward list. Steps

Deliverable 3:
In this third deliverable, you are going to be using the Standard Template Library Data
Structures. vector, stack, queue, forward list.
Steps :
Select 3 data structures out of these 4 and implement them using the class in your
project. Build your data structure, using at least 5 objects from your class.
Print the content of each data structure to note how objects are stored and
retrieved based on the data structure
To be returned:
-Your programs.
-Screen shots of your programs execution.
my class was planet, here is my code:
//Planet.cpp
#include "Planet.h"
#include
Planet::Planet()
{
name ="";
distance_From_Sun=0;
has_Life = false;
classification='U';
diameter=0.0;
}
// Parameterized constructor
Planet::Planet(string name, int distance_From_Sun, bool has_Life, char classification, double diameter)
{
this->name = name;
this->distance_From_Sun = distance_From_Sun;
this->has_Life=has_Life;
this->classification=classification;
this->diameter=diameter;
}
// Setters functions which initialize the instance variables
void Planet::setName(std::string name){ this->name = name; }
void Planet::setDistanceFromSun(int distance){ distance_From_Sun = distance; }
void Planet::setHasLife(bool life){ has_Life = life; }
void Planet::setClassification(char classification){ this->classification = classification; }
void Planet::setDiameter(double diameter){ this->diameter = diameter; }
// Getters functions
string Planet::getName() const { return name; }
int Planet::getDistanceFromSun() const { return distance_From_Sun; }
bool Planet::hasLife() const { return has_Life; }
char Planet::getClassification() const { return classification; }
double Planet::getDiameter() const { return diameter; }
// prints Planet object
void Planet::printObject() const {
cout "Name: " name endl;
cout "Distance from Sun: " distance_From_Sun " million miles" endl;
cout "Has life: "(has_Life ? "Yes" : "No") endl;
cout "Classification: " classification endl;
cout "Diameter: " diameter " miles" endl;
}
// Function which Compare two Planet class objects
int Planet::compare(const Planet& other) const {
if (distance_From_Sun other.distance_From_Sun){
return -1;
} else if (distance_From_Sun == other.distance_From_Sun){
return 0;
} else {
return 1;
}
}
please screen shot program of it working its giving an error on my end
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

12.6 Prediction

Answered: 1 week ago

Question

Does it have correct contact information?

Answered: 1 week ago