Need help with this class and function please!!!
#include <iostream>
using namespace std;
class Team {
string teamId;
string name;
string coach;
Team *next;
friend class teamlist;
public:
Team * getNext();
return next;
void setNext(Team *r);
next=r;
string getTeamId();
return teamId;
void setTeamId(string aTeamId);
teamId = aTeamId;
string getName();
return name;
void setName(string aName);
name = aName;
string getCoach();
return coach;
void setCoach(string aCoach);
coach = aCoach;
}
PLEASE DON'T FORGET TO UPVOTE THE ANSWER, IF YOU LIKE IT.
As you have already written the class Team, I am answering the part of the ques asking for the class teamlist.
=========================================================
class teamlist{
Team* head;
Team* tail;
int noOfTeams;
public:
teamlist(){
head=NULL;
tail=NULL;
noOfTeams=0;
}
void addTeam(Team *t){
Team *team=new team(t);
if(head==NULL){
head=team;
tail=team;
}
else{
tail->next=team;
tail=tail->next;
}
noOfTeams++;
}
void readData(char* filename){
ifstream inFile;
inFile.open(filename);
while(!inFile.eof()){
noOfTeams++;
string id,name,coach;
inFile.getline(cin,id);
inFile.getline(cin,name);
inFile.getline(cin,coach);
Team* newteam=new Team();
newteam.setTeamId(id);
newteam.setName(name);
newteam.setCoach(coach);
if(head==NULL){
head=newteam;
tail=newteam;
}
else{
tail->next=newteam;
tail=tail->next;
}
}
}
void printTeams(){
Team* temp=head;
while(temp!=NULL){
cout<<temp->teamId<<endl<<temp->name<<endl<<temp->coach<<endl;
temp=temp->next;
}
}
Team* getTeamRef(string id){
Team* temp=head;
while(temp!=NULL){
if(id.compare(temp->teamId)==0) return temp;
temp=temp->next;
}
return NULL;
}
int getNumTeams(){
return noOfTeams;
}
};
Need help with this class and function please!!! #include <iostream> using namespace std; c...
USING THIS CODE: #include <iostream> #include <string> using namespace std; class Contact { //this class cannot be viewed from outside of the private class. //only the class functions within the class can access private members. private: string name; string email; string phone; //the public class is accessible from anywhere outside of the class //however can only be within the program. public: string getName() const { return name; } void setName(string name) { this->name = name; } string getEmail() const {...
//LinkedList import java.util.Scanner; public class PoD { public static void main( String [] args ) { Scanner in = new Scanner( System.in ); LinkedList teamList = new LinkedList(); final int TEAM_SIZE = Integer.valueOf(in.nextLine()); for (int i=0; i<TEAM_SIZE; i++) { String newTeamMember = in.nextLine(); teamList.append(newTeamMember); } while (in.hasNext()) { String removeMember = in.nextLine(); teamList.remove(removeMember); } System.out.println("FINAL TEAM:"); System.out.println(teamList); in.close(); System.out.print("END OF OUTPUT"); } } =========================================================================================== //PoD import java.util.NoSuchElementException; /** * A listnked list is a sequence of nodes with...
#include "name.h" #include "contact.h" using namespace std; class ContactList; typedef class Node* NodePtr; class Node { Contact item; NodePtr next; friend class ContactList; }; class ContactList { public: ContactList(char* clfile) ; ~ContactList(); void display (ostream & output) const; int insert (Contact record_to_insert); int insert (ContactList contact_list); int remove (Contact record_to_delete); int size () const; int save () const; void find_by_lname (ostream & output, string lname) const; void...
could somone please help me to complete this ! public class MyLinkedList<AnyType> { private Node<AnyType> head, tail; private int size; public MyLinkedList() { this.head = null; this.tail = null; this.size = 0; } //1.Insert a node at the end of the list public void insert(AnyType data) { Node<AnyType> newNode = new Node(); newNode.data = data; if (head == null) { head = newNode; tail = newNode; head.next = null; tail.next = null; } else { tail.next = newNode; tail =...
#include <iostream> using namespace std; struct ListNode { float value; ListNode *next; }; ListNode *head; class LinkedList { public: int insertNode(float num); void deleteNode(float num); void destroyList(); void displayList(); LinkedList(void) {head = NULL;} ~LinkedList(void) {destroyList();} }; int LinkedList::insertNode(float num) { struct ListNode *newNode, *nodePtr = head, *prevNodePtr = NULL; newNode = new ListNode; if(newNode == NULL) { cout << "Error allocating memory for new list member!\n"; return 1; } newNode->value = num; newNode->next = NULL; if(head==NULL) { cout << "List...
Please rewrite this function using recursive function #include using namespace std; struct Node { char ch; Node* next; }; class LinkedList { Node* head; public: LinkedList(); ~LinkedList(); void add(char ch); bool find(char ch); bool del(char ch); friend std::ostream& operator<<(std::ostream& out, LinkedList& list); }; LinkedList::LinkedList() { head = NULL; } LinkedList::~LinkedList() { Node* cur = head, * tmp; while (cur != NULL) { tmp = cur->next; delete cur; cur = tmp; } } void LinkedList::add(char ch) { Node* cur = head,...
Study the recursive instance method length()of MyLinkedList2 class and its associated auxiliary method. Then solve (a), (b), and (c) below in a similar way: (a) Convert the method public Element find(Object obj)of MyLinkedList2 class to a recursive one. Use an auxiliary private method. (b) Convert the method public String toString( )of MyLinkedList2 class to a recursive one such that it returns the string representation of a linked list in the form: {ValueDatum1 valueDatum2 valueDatum3 . . . valueDatumN-1 valueDatumN} Use an auxiliary private method....
#include <iostream> #include <fstream> using namespace std; //constants const int CAP = 100; //function prototypes bool openFile(ifstream &); void readData(ifstream &, int [], int &); void printData(const int [], int); void sum(const int[], int); void removeItem(int[], int &, int); int main() { ifstream inFile; int list[CAP], size = 0; if (!openFile(inFile)) { cout << "Program terminating!! File not found!" << endl; return -1; } //read the data from the file readData(inFile, list, size); inFile.close(); cout << "Data in file:" <<...
PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() { amount = 0.0; } }; //============================================================================ // Linked-List class definition //============================================================================ /** * Define a class containing data members and methods to *...
a7q3.cc File #include <iostream> #include <cstring> #include "ArrayList.h" using namespace std; // Algorithm copy(s) // Pre: s :: refToChar // Post: memory allocated on heap to store a copy // Return: reference to new string char *copy(char *s) { char *temp = new char[strlen(s)+1]; strcpy(temp,s); return temp; } void test_ListOperations(){ cout << "testing createList" << endl; List *myList = createList(10); if (myList == NULL){ cout << "createList failed" << endl; return; } else{ cout << "createList succeeded"...