Thread has been deleted
Last comment
anyone have chegg?
 | 
Canada rayrayrayray 
Anyone have a chegg account and want to unlock an answer for me? have an exam tomorrow and i dont really want to pay 15$ for it
2019-12-11 07:55
Topics are hidden when running Sport mode.
#1
 | 
North America niftynick 
post the link to the question
2019-12-11 07:56
#5
 | 
North America niftynick 
#4
2019-12-11 07:58
#6
 | 
Canada rayrayrayray 
theres no #4
2019-12-11 07:59
#7
 | 
North America niftynick 
i posted the answer in the thread
2019-12-11 08:00
#2
 | 
Canada rayrayrayray 
opps
2019-12-11 07:57
#4
 | 
North America niftynick 
Given below is the modified code for the question. Please don't forget to rate the answer if it was helpful. Thank you #include <iostream> using namespace std; template <class T> class OrderedIterator; //forward declaration template <class T> class OrderedSet { // ================= friend class OrderedIterator<T>; int capacity; //maximum size of the container int size; //number of actual elements in the container T **buffer; //pointer to memory for holding elements public: OrderedSet(int aCapacity = 100); OrderedSet(const OrderedSet<T> & c); ~OrderedSet(); typedef OrderedIterator<T> iterator; int getSize() const {return size;} //answer number of elements bool isFull()const {return size == capacity;} //answer if full OrderedSet<T> & addLast( T & element); //add to end OrderedSet<T> & addFirst( T & element); //add to front T & removeLast();//remove last element T & removeFirst(); //remove first element OrderedSet<T> & remove(const T & element); //remove all items == element iterator begin(void); //provide an start iterator iterator end(void); //provide an end iterator bool contains(const T &element); //checks if given element is present in set void expand(); //doubles the capacity void print(){ cout << "Set\n"; cout << "==========\n"; for(int i=0; i<size; i++) cout << *buffer[i]; } }; template <class T> class OrderedIterator { //The iterator class // =============== int index; //location in the container being iterated OrderedSet<T> & s; //container being iterated public: OrderedIterator(OrderedSet<T> & set, int position = 0); OrderedIterator<T> & operator++(int); //to advance to next element T & operator*(); //to get element bool operator==(const OrderedIterator<T> & iter); bool operator!=(const OrderedIterator<T> & iter); }; //Constructor Implementations template <class T> OrderedSet<T>::OrderedSet(int aCapacity) : capacity(aCapacity),size(0), buffer(new T*[aCapacity]) {} template <class T> OrderedSet<T>::OrderedSet(const OrderedSet<T> & c) : capacity(c.capacity), size(c.size), buffer(new T*[c.capacity]) { for(int i=0; i< capacity; i++) buffer[i] = c.buffer[i]; } template <class T> OrderedSet<T>::~OrderedSet() {delete [] buffer; } //Method Implementations template <class T> OrderedSet<T> & OrderedSet<T>::addLast(T & element){ if(!contains(element)) { if(isFull()) expand(); buffer[size++] = &element; } return *this; } template <class T> OrderedSet<T> & OrderedSet<T>::addFirst(T & element){ if(!contains(element)) { if(isFull()) expand(); size++; for(int i=size-1; i>0; i--) buffer[i] = buffer[i-1]; buffer[0] = &element; } return *this; } template <class T> T & OrderedSet<T>::removeLast(){ return * buffer[size--]; } template <class T> T & OrderedSet<T>::removeFirst(){ T* temp; size--; temp = buffer[0]; for(int i=0; i<size; i++) buffer[i] = buffer[i+1]; return *temp; } template <class T> OrderedSet<T> & OrderedSet<T>::remove(const T & item){ //remove all elements which are == item (assume T implements == oper) int newIndex = 0; for(int i=0; i<size; i++){ if(*buffer[i] != item) buffer[newIndex++] = buffer[i]; } size = newIndex; return *this; } template <class T> bool OrderedSet<T>::contains(const T &element) { for(int i=0; i<size; i++) { if(*buffer[i] == element) return true; } return false; } template <class T> void OrderedSet<T>::expand() { capacity *= 2; T** temp = new T*[capacity]; for(int i = 0; i < size; i++) temp[i] = buffer[i]; delete buffer; buffer = temp; } template <class T> typename OrderedSet<T>::iterator OrderedSet<T>::begin(void) { //provide an start iterator return OrderedIterator<T>(*this); } template <class T> typename OrderedSet<T>::iterator OrderedSet<T>::end(void) { //provide an end iterator return OrderedIterator<T>(*this, size); } template <class T> OrderedIterator<T>::OrderedIterator(OrderedSet<T> & set, int position) : index(position), s(set) {} template <class T> OrderedIterator<T> & OrderedIterator<T>::operator++(int) { index++; return *this; } template <class T> T & OrderedIterator<T>::operator*() { return *(s.buffer[index]); } template <class T> bool OrderedIterator<T>::operator==(const OrderedIterator<T> & iter) { return (&s == &(iter.s)) && (index == iter.index); } template <class T> bool OrderedIterator<T>::operator!=(const OrderedIterator<T> & iter) { return !(*this == iter); } class BankAccount{ double balance; string owner; public: BankAccount(string anOwner, double anAmount):owner(anOwner), balance(anAmount) {} bool operator== (const BankAccount & b) {return owner == b.owner && balance == b.balance;} bool operator!= (const BankAccount & b) {return !(*this == b);} void printOn(ostream & o) const { o << owner << ": $" << balance << "\n"; } }; ostream & operator<<(ostream & o, const BankAccount & b){ b.printOn(o); return o; } //Example of how the collection and iterator could be used int main() { BankAccount b1("John", 100.0), b2("Bill", 50.0), b3("Robert", 200.0), b4("Alice",150.0); OrderedSet<BankAccount> accounts(3); //initial capacity of 3, will expand when more added accounts.addLast(b1).addLast(b2).addLast(b3).addLast(b4).addLast(b2); //b2 is duplicate and will not be added for(OrderedSet<BankAccount>::iterator itr = accounts.begin(); itr != accounts.end(); itr++) cout << *itr; accounts.print(); accounts.remove(b2); accounts.print(); return 0; }//end main output ====== John: $100 Bill: $50 Robert: $200 Alice: $150 Collection ========== John: $100 Bill: $50 Robert: $200 Alice: $150 Collection ========== John: $100 Robert: $200 Alice: $150
2019-12-11 07:57
#8
 | 
North America niftynick 
pastebin.com/L9McnLPC Does this work?
2019-12-11 08:04
SMASH
2.44
HAVU
1.43
Hard4U
2.60
Astro
1.49
Airborne
1.31
FURY
3.30
Bet value
Amount of money to be placed
Winning
Odds total ratio
-
Login or register to add your comment to the discussion.