This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "SortedVector.h" // Found in https://github.com/CSCI235-Ayzman/SortedStructures | |
#include "SortedLinkedList.h" // Found in https://github.com/CSCI235-Ayzman/SortedStructures | |
using namespace std; | |
class Residence | |
{ | |
public: | |
Residence(double newPrice = 1.0) : price(newPrice) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
class Residence { | |
public: | |
Residence(double newPrice = 0.0) : price(newPrice) {} | |
virtual ~Residence() {} | |
double getPrice() { return price; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
class Residence { | |
public: | |
Residence(double newPrice = 1.0) : price(newPrice) {} | |
virtual ~Residence() {} | |
double getPrice() { return price; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
int find(const T& item, T* array, unsigned int size) | |
{ | |
for (unsigned int i = 0; i < size; ++i) | |
{ | |
// Assume T has properly overloaded operator== | |
if (array[i] == item) | |
{ | |
return i; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T1, typename T2> | |
struct Pair{ | |
T1 first; | |
T2 second; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Polygon{ | |
public: | |
virtual ~Polygon() {} | |
int perimeter(){ | |
double sum = 0; | |
for(int i = 0; i < sides.size(); i++){ | |
sum += sides[i]; | |
} | |
return sum; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T> | |
string toString(T type) { | |
std::ostringstream strs; | |
strs << type; | |
return strs.str(); | |
} | |
class Instructor { | |
public: | |
Instructor(string theName) : name(theName) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void LinkedList::skipAndRemove(int skipNum, int removeNum){ | |
// There is either currently nothing in the list | |
// or you're instructed not to remove anything | |
if (head == NULL || removeNum == 0) { | |
return; | |
} | |
// Skip nothing; therefore, remove everything | |
if (skipNum == 0) { | |
this->clear(); // Assume this exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note that this is an interesting kind of tree, where there is no overall structure that contains nodes. | |
// Instead the tree is itself a node. | |
template<class ItemType> | |
class Tree { | |
private: | |
Tree<ItemType> * left; | |
Tree<ItemType> * right; | |
ItemType data; | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
template<class T> | |
struct TreeNode{ | |
T data; | |
TreeNode<T> * right; | |
TreeNode<T> * left; | |
}; |
OlderNewer