build a template class
Budget: $10 – $30 USD
The details are provided in the file. the output should match the one on pdf, use these ints for the txt file.
7 2 a
3 4 a
4 5 a
3 5 d
2 6 a
4 4 a
12 1 D
2 8 a
8 2 d
tsllist.h header file....
#ifndef INT_LINKED_LIST
#define INT_LINKED_LIST
#include <iostream>
template <class T>
class TSLList {
public:
// Constructor
TSLList() {
head = nullptr;
}
//D Destructor
~TSLList() {
clearList();
}
// prints the info content and address of each node in the list
void printAll() const {
for (TSLLNode *tmp = head; tmp != nullptr; tmp = tmp->next)
std::cout << "->[" << tmp->info << "," << tmp << "]";
std::cout << std::endl;
}
// Inserts node in order (see assignment specification for details)
void insertInOrder(T);
// Deletes an occurrence of argument (see assignment specification for details)
T deleteVal(T);
// Deletes all occurrences of argument (see assignment specification for details)
void deleteAllVal(T el);
// Clears the list (deallocates memory - see assignment specification for details)
void clearList();
private:
// Node stored in linked list
struct TSLLNode {
TSLLNode(T el = T()) {
info = el;
next = nullptr;
}
T info;
TSLLNode *next;
};
TSLLNode *head; // head of the list
};
#endif
rectangle.h header file
#ifndef RECTANGLE_H
#define RECTANGLE_H
#include <iostream>
using std::ostream;
class Rectangle
{
public:
Rectangle(int l = 0, int w = 0) // default constructor
{ length = l; width = w; area = length * width; }
void setLength(int l) // lengthgth mutator (setter) - updates area member
{ length = l; area = length * width; }
void setWidth(int w) // width mutator (setter) - updates area member
{ width = w; area = length * width; }
int getLength() const // lengthgth accessor (getter)
{ return length; }
int getWidth() const // width accessor (getter)
{ return width; }
int getArea() const // area accessor (getter)
{ return area; }
friend ostream& operator << (ostream& os, const Rectangle & rect) // outputs a Rectangle object
{
os << "[L:" << rect.length << " W:" << rect.width << " (A " << rect.area << ")]";
return os;
}
// implement overloads below
bool operator<(const Rectangle &);
bool operator<=(const Rectangle &);
bool operator>(const Rectangle &);
bool operator>=(const Rectangle &);
bool operator==(const Rectangle &);
bool operator!=(const Rectangle &);
private:
int length; // length data member
int width; // width data member
int area; // area data member
};
#endif
7 2 a
3 4 a
4 5 a
3 5 d
2 6 a
4 4 a
12 1 D
2 8 a
8 2 d
tsllist.h header file....
#ifndef INT_LINKED_LIST
#define INT_LINKED_LIST
#include <iostream>
template <class T>
class TSLList {
public:
// Constructor
TSLList() {
head = nullptr;
}
//D Destructor
~TSLList() {
clearList();
}
// prints the info content and address of each node in the list
void printAll() const {
for (TSLLNode *tmp = head; tmp != nullptr; tmp = tmp->next)
std::cout << "->[" << tmp->info << "," << tmp << "]";
std::cout << std::endl;
}
// Inserts node in order (see assignment specification for details)
void insertInOrder(T);
// Deletes an occurrence of argument (see assignment specification for details)
T deleteVal(T);
// Deletes all occurrences of argument (see assignment specification for details)
void deleteAllVal(T el);
// Clears the list (deallocates memory - see assignment specification for details)
void clearList();
private:
// Node stored in linked list
struct TSLLNode {
TSLLNode(T el = T()) {
info = el;
next = nullptr;
}
T info;
TSLLNode *next;
};
TSLLNode *head; // head of the list
};
#endif
rectangle.h header file
#ifndef RECTANGLE_H
#define RECTANGLE_H
#include <iostream>
using std::ostream;
class Rectangle
{
public:
Rectangle(int l = 0, int w = 0) // default constructor
{ length = l; width = w; area = length * width; }
void setLength(int l) // lengthgth mutator (setter) - updates area member
{ length = l; area = length * width; }
void setWidth(int w) // width mutator (setter) - updates area member
{ width = w; area = length * width; }
int getLength() const // lengthgth accessor (getter)
{ return length; }
int getWidth() const // width accessor (getter)
{ return width; }
int getArea() const // area accessor (getter)
{ return area; }
friend ostream& operator << (ostream& os, const Rectangle & rect) // outputs a Rectangle object
{
os << "[L:" << rect.length << " W:" << rect.width << " (A " << rect.area << ")]";
return os;
}
// implement overloads below
bool operator<(const Rectangle &);
bool operator<=(const Rectangle &);
bool operator>(const Rectangle &);
bool operator>=(const Rectangle &);
bool operator==(const Rectangle &);
bool operator!=(const Rectangle &);
private:
int length; // length data member
int width; // width data member
int area; // area data member
};
#endif