35 lines
809 B
C++
35 lines
809 B
C++
//************************ cirSLList.cpp **************************
|
|
|
|
#include <iostream>
|
|
#include "cirSLList.h"
|
|
#include "circle.h"
|
|
|
|
using namespace std;
|
|
|
|
cirSLList::~cirSLList() {
|
|
for (cirSLLNode *p; !isEmpty(); ) {
|
|
p = head->next;
|
|
delete head;
|
|
head = p;
|
|
}
|
|
}
|
|
|
|
void cirSLList::addToTail(double el) {
|
|
if (tail != 0) { // if list not empty;
|
|
tail->next = new cirSLLNode(el);
|
|
tail = tail->next;
|
|
}
|
|
else head = tail = new cirSLLNode(el);
|
|
}
|
|
|
|
void cirSLList::displayAllElements() {
|
|
int i = 1;
|
|
for (cirSLLNode* tmp = head; tmp != 0; tmp = tmp->next) {
|
|
cout << i << ". ";
|
|
cout << "Radius: " << tmp->info.getRadius() << " - ";
|
|
cout << "Area: " << tmp->info.calculateArea() << endl;
|
|
i++;
|
|
}
|
|
cout << endl;
|
|
}
|
|
|