Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "BballRoster.h"
- #include <iostream>
- using namespace std;
- BballRoster::BballRoster()
- {
- head = nullptr;
- tail = nullptr;
- }
- bool BballRoster::rosterEmpty() const
- {
- Node* p;
- p = head;
- int i = 0;
- while (p != nullptr)
- {
- p = p->next;
- i++;
- }
- if (i == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- int BballRoster::howManyPlayers() const
- {
- Node* p;
- p = head;
- int i = 0;
- while (p != nullptr)
- {
- p = p->next;
- i++;
- }
- return i;
- }
- bool BballRoster::signPlayer(const std::string& firstName, const std::string&lastName, const SomeType& value)
- {
- //put data into node
- Node* p;
- p = new Node;
- p->firstname = firstName;
- p->lastname = lastName;
- p->value = value;
- //create unsorted linked list
- if (rosterEmpty() == true)
- {
- head = p;
- tail = p;
- head->next = nullptr;
- p->prev = nullptr;
- }
- else {
- tail->next = p;
- p->prev = tail;
- tail = p;
- tail->next = nullptr;
- }
- //sort linked list
- Node* n;
- Node* k;
- string temp;
- string temp2;
- string temp3;
- for (n = head->next; n != nullptr; n = n->next)
- {
- for (k = head; k != nullptr; k = k->next)
- {
- if (n->lastname < k->lastname)
- {
- temp = n->lastname;
- temp2 = n->firstname;
- temp3 = n->value;
- n->lastname = k->lastname;
- n->firstname = k->firstname;
- n->value = k->value;
- k->lastname = temp;
- k->firstname = temp2;
- k->value = temp3;
- }
- else if (n->lastname == k->lastname)
- {
- if (n->firstname < k->firstname)
- {
- temp = n->lastname;
- temp2 = n->firstname;
- temp3 = n->value;
- n->lastname = k->lastname;
- n->firstname = k->firstname;
- n->value = k->value;
- k->lastname = temp;
- k->firstname = temp2;
- k->value = temp3;
- }
- }
- }
- }
- return true;
- }
- bool BballRoster::resignPlayer(const std::string& firstName, const std::string&lastName, const SomeType& value)
- {
- return false;
- }
- bool BballRoster::signOrResign(const std::string& firstName, const std::string&lastName, const SomeType& value)
- {
- return false;
- }
- bool BballRoster::renouncePlayer(const std::string& firstName, const std::string& lastName)
- {
- return false;
- }
- bool BballRoster::playerOnRoster(const std::string& firstName, const std::string& lastName) const
- {
- return false;
- }
- bool BballRoster::lookupPlayer(const std::string& firstName, const std::string&lastName, SomeType& value) const
- {
- return true;
- }
- bool BballRoster::choosePlayer(int i, std::string& firstName, std::string&lastName, SomeType& value) const
- {
- return true;
- }
- void BballRoster::swapRoster(BballRoster& other)
- {
- }
- void BballRoster::printRoster()
- {
- Node* p = new Node;
- p = head;
- while (p != nullptr)
- {
- cout << p->lastname << " " << p->firstname << " " << p->value << endl;
- p = p->next;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement