Question

Please help ASAP! C ++, linked list, etc. everything for the project is in the link...

Please help ASAP! C ++, linked list, etc.

everything for the project is in the link below.

https://www.zipshare.com/download/eyJhcmNoaXZlSWQiOiIzZDIyN2UzYi1kNGFhLTRlMzEtYjMzZi00MDhmYzNiMjk3ZGMiLCJlbWFpbCI6Im1pMTQzNEBnbWFpbC5jb20ifQ==

You should turn it in by blackboard. Each task should be in a separate unzipped folder named YourLastName_YourFirstInitial_taskN, where N is the task number inside a zipped file named: YourLastName_YourFirstInitial.zip.

You may use code you have written previously and you may ask other members of the class questions about the assignment. However, you must do your own assignment; you may not use anyone else’s code. You must write your own code. Also, remember any task that doesn’t compile will receive 0 points.

Task 1 - 40 points

Implement a linked list.

Write a C++ class (or set of classes) that implements a linked list.  The data contained in the nodes are integers.  The maximum number of nodes in the list is 100.  Implement at least the following functions:

·   Constructor and destructor;

·   void insert (int number); - inserts an element with the value number at the beginning of the list;

·   int isEmpty(); - returns 1 if the list is empty, 0 otherwise;

·   int numOfElements(); - returns the number of elements in the list.

You do not need to include any other classes for full credit, but you can if you choose.

Clean the solution of the project and put the entire project including source code in a folder named YourLastName_YourFirstInitial_task1.

Task 2 – 50 points

Since it’s fall we need to write a program to help our favorite team keep track of its players performance. The file that will print out the player’s stats is done. You are given a class for a player; however, a football team is composed of offensive and defensive players. So you need to build on the player class. It is rare that a player is both, so we will assume our team has exclusively offensive and defensive players. All players have a name, number and they all play for some number of minutes. However, a defensive player is measured by the number of tackles they get, while an offensive player is measured by the number of yards they get. For this assignment you need to create 2 classes that inherit from a class, player that has already been written. This class makes no calculations; it just holds data on each player. Your class will be used by the main function in main.cpp to print the team’s stats, so it must follow the guidelines below. You may not change the files given in any way.

Download the Football project and unzip it. It will not compile because it is missing some classes. The main.cpp, player.h and player.cpp files must not be changed in any way. Ten points will be deducted for each modified file.

The project needs 4 files added: defense.h, defense.cpp, offense.h, offense.cpp. There are also a few questions that must be answered.

The files should be formatted similar to the player class files. The classes need to have the following:

defense class variables:

int tackles;

defense class methods:

Defense(string name);

setMinutesPlayed(int minutes);

setTackles(int tackles);

printStats() const;

offense class variables:

int yards;

offense class methods:

Offense(string name);

setMinutesPlayed(int minutes);

setYards(int yards);

printStats() const;

*Note: You must decide on the return types, visibility and any additional modidifiers for these methods.

Rules:

Your classes must inherit from the base class player.

You should not recode anything. If the base class already does something, don’t put it in your derived class. Use what is already there.

You should follow the coding conventions of the program given.

Do not include .cpp files

All files should have a brief description at the beginning that includes the title of the file and your name. The code should have comments describing each method and large section. See the provided code for examples.

All 4 of the methods listed above must be implemted. You may add methods, but it is not necessary.

This is just a suggestion, but the solution averages exactly one line of code inside each method, so if a method has 2 lines of code another should have 0 lines of code. There is no trick here either with crazy lines that call multiple functions or anything else. Basically, if you are writing many lines of code per method, you need to review inheritance or polymorphism.

All classes should include all needed libraries.

The final output should look like the following:

Questions:

On lines 29 to 33 of main.cpp, why is there an ‘&’ before the player variables?

For lines 45 to 49 of main.cpp, why not use a loop?

On lines 10, 11 and 52 of player.h, what do the #ifndef, #define and #endif preprocessor commands do?

On line 20 of player.h, the string name is private, what did you have to do because of this?

On lines 24 of player.h, why does minutes played have to be protected, not private?

On line 43 of player.h, why is the function assigned zero?

On line 49 of player.h, what does the word ‘const’ do?

What method should be entirely in the base class? Why?

Which class is an abstract class? Why?

Name one thing you learned or had forgotten and remembered in this task.

From the menu "Build-> Clean Solution" of Visual Studio remove the binary files from the project.

Answer the above 10 questions in a text file and the cleaned solution of the project with the source code and put it all in a folder named YourLastName_YourFirstInitial_task2.

Task 3 – 10 points

Open ANote project, from the zip folder you downloaded and build the project.  There is one compilation error. Fix it.

From the menu "Build-> Clean Solution" of Visual Studio remove the binary files from the project.

Clean the solution of the project and put the entire project including source code in a folder named YourLastName_YourFirstInitial_task3.

Thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

task1

//EXAMPLE PROGRAM FOR SINGLE LINKED LIST
# include <iostream.h>
# include <conio.h>
# include <stdlib.h>
struct node
{
int number;
node *next;
};
class singlelist
{
node *first,*prev,*temp,*curr;
public:
singlelist()
{
first=NULL;
}
void create()
{
cout<<"Stop by -999"<<endl;
temp=new node;
cout<<"Enter the numbers ";
cin>>temp->number;
while(temp->number!=-999)
{
   temp->next=NULL;
   if(first==NULL)
   {
   first=temp;
   prev=first;
   }
   else
   {
   prev->next=temp;
   prev=temp;
   }
temp=new node;
cin>>temp->number;
} //end of while
}

void deletenode()
{
int num;
cout<<"\nEnter the number to delete ";
cin>>num;
if(first->number==num)
{
first=first->next;
return;
}
else
{
prev=first;
curr=first->next;
while(curr->next!=NULL)
{
if(curr->number==num)
{
prev->next=curr->next;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==num)
{
prev->next=NULL;
return;
}
cout<<"\n No such number";
}

void insertbefore()
{
int nu;
temp=new node;
cout<<"\n Enter the number ";
cin>>temp->number;
cout<<"\n before the number ";
cin>>nu;
temp->next=NULL;
prev=first;
curr=first;
/* if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}*/
if(curr->number==nu)
{
temp->next=first;
first=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
cout<<"\n No such number ";
}

void insertafter()
{
int nu;
temp=new node;
cout<<"\n Enter the number ";
cin>>temp->number;
cout<<"\n After the number ";
cin>>nu;
temp->next=NULL;
prev=first;
curr=first;
/* if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}*/
if(curr->number==nu)
{
temp->next=first->next;
first->next=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
temp->next=curr->next;
curr->next=temp;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
curr->next=temp;
temp->next=NULL;
return;
}
cout<<"\n No such number ";
}

void print()
{
cout<<" The list is "<<endl;
cout<<" ----------- "<<endl;
temp=first;
while(temp!=NULL)
{
cout<<temp->number<<"-->";
temp=temp->next;
}
cout<<"Nil"<<endl;
getch();
}
};

void main()
{
int ch=0;
singlelist s;
clrscr();
cout<<" Linked List creation \n";
s.create();
clrscr();
while(ch!=5)
{
clrscr();
cout<<"\n 1.Insert Before";
cout<<"\n 2.Insert After";
cout<<"\n 3.Delete ";
cout<<"\n 4.Print ";
cout<<"\n 5.Exit ";
cout<<"\n Enter your choice ";
cin>>ch;
switch(ch)
{
   case 1:
       s.insertbefore();
       s.print();
       break;
   case 2:
       s.insertafter();
       s.print();
       break;
   case 3:
       s.deletenode();
       s.print();
       break;
   case 4:
       s.print();
       break;
   case 5:
       s.print();
       exit(1);
}
}
getch();
}

task2)

//EXAMPLE PROGRAM FOR SINGLE LINKED LIST
# include <iostream.h>
# include <conio.h>
# include <stdlib.h>
struct node
{
int number;
node *next;
};
class singlelist
{
node *first,*prev,*temp,*curr;
public:
singlelist()
{
first=NULL;
}
void create()
{
cout<<"Stop by -999"<<endl;
temp=new node;
cout<<"Enter the numbers ";
cin>>temp->number;
while(temp->number!=-999)
{
   temp->next=NULL;
   if(first==NULL)
   {
   first=temp;
   prev=first;
   }
   else
   {
   prev->next=temp;
   prev=temp;
   }
temp=new node;
cin>>temp->number;
} //end of while
}

void deletenode()
{
int num;
cout<<"\nEnter the number to delete ";
cin>>num;
if(first->number==num)
{
first=first->next;
return;
}
else
{
prev=first;
curr=first->next;
while(curr->next!=NULL)
{
if(curr->number==num)
{
prev->next=curr->next;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==num)
{
prev->next=NULL;
return;
}
cout<<"\n No such number";
}

void insertbefore()
{
int nu;
temp=new node;
cout<<"\n Enter the number ";
cin>>temp->number;
cout<<"\n before the number ";
cin>>nu;
temp->next=NULL;
prev=first;
curr=first;
/* if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}*/
if(curr->number==nu)
{
temp->next=first;
first=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
cout<<"\n No such number ";
}

void insertafter()
{
int nu;
temp=new node;
cout<<"\n Enter the number ";
cin>>temp->number;
cout<<"\n After the number ";
cin>>nu;
temp->next=NULL;
prev=first;
curr=first;
/* if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}*/
if(curr->number==nu)
{
temp->next=first->next;
first->next=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
temp->next=curr->next;
curr->next=temp;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
curr->next=temp;
temp->next=NULL;
return;
}
cout<<"\n No such number ";
}

void print()
{
cout<<" The list is "<<endl;
cout<<" ----------- "<<endl;
temp=first;
while(temp!=NULL)
{
cout<<temp->number<<"-->";
temp=temp->next;
}
cout<<"Nil"<<endl;
getch();
}
};

void main()
{
int ch=0;
singlelist s;
clrscr();
cout<<" Linked List creation \n";
s.create();
clrscr();
while(ch!=5)
{
clrscr();
cout<<"\n 1.Insert Before";
cout<<"\n 2.Insert After";
cout<<"\n 3.Delete ";
cout<<"\n 4.Print ";
cout<<"\n 5.Exit ";
cout<<"\n Enter your choice ";
cin>>ch;
switch(ch)
{
   case 1:
       s.insertbefore();
       s.print();
       break;
   case 2:
       s.insertafter();
       s.print();
       break;
   case 3:
       s.deletenode();
       s.print();
       break;
   case 4:
       s.print();
       break;
   case 5:
       s.print();
       exit(1);
}
}
getch();
}

task3)

Add a comment
Know the answer?
Add Answer to:
Please help ASAP! C ++, linked list, etc. everything for the project is in the link...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Ever...

    C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Туре String String String Attribute title author ISBN Textbook* next Library class should have a head node as an attribute to keep the list of the books. Also, following member...

  • JAVA please Java problem that has to be in doubly linked list. It is game problem...

    JAVA please Java problem that has to be in doubly linked list. It is game problem that I have to keep of the players' scores. this should have a Java blueprint class named player   It should have two fields, the name and score and include the constructors, toString() method, and getters and setters. Scores must be kept in ascending order (smallest at the front ) in a doubly linked list. It has menu as well: Load original data Print the...

  • You need to implement a queue based on the doubly linked list. (In C++) **PLEASE follow...

    You need to implement a queue based on the doubly linked list. (In C++) **PLEASE follow the format** **Don't worry about the readme.txt** THANK YOU SO SO MUCH! You have to implement the doubly linked list in DList.h and DList.cpp and the queue in the LinkedQueue.h and LinkedQueue.cpp; all as template classes. You have to provide the main.cpp file as we discussed in class to allow the user to interact with your queue using enqueue, dequeue, front, back, size, empty,...

  • I need help finding the error in my code for my Fill in the Blank (Making a Player Class) in C++. Everything looks good...

    I need help finding the error in my code for my Fill in the Blank (Making a Player Class) in C++. Everything looks good to me but it will not run. Please help... due in 24 hr. Problem As you write in your code, be sure to use appropriate comments to describe your work. After you have finished, test the code by compiling it and running the program, then turn in your finished source code. Currently, there is a test...

  • Answer in eclispe please!!! Do the following: 1. Create a package named, “prob3” and a class...

    Answer in eclispe please!!! Do the following: 1. Create a package named, “prob3” and a class named, “Games2”. 2. Create a Player class and add this code: public class Player { private String name; private int points; public Player(String name, int points) { this.name = name; this.points = points; } public String getName() { return name; } public int getPoints() { return points; } @Override public String toString() { return "name=" + name + ", points=" + points; } }...

  • You will implement 2 games, the Prisoner's Dilemma, The Stag Hunt and compare their results for...

    You will implement 2 games, the Prisoner's Dilemma, The Stag Hunt and compare their results for your report. After you finish implementing everything else, you will only need to change one function to make it a prisoner's dilemma or a stag hunt game 1) main.cpp: This is the driver program that sets up the game and plays it. This is where you will call functions to print the statistics. The required statistics is percentage of players using strategy 1 (cooperate...

  • Please use C++ CS3358 Insert and delete a node Programming Project 2: The linked list -...

    Please use C++ CS3358 Insert and delete a node Programming Project 2: The linked list - Reference: chapter 18: Create an array of 15 student records that should not be sorted Create a liked list of 15 student record nodes. Each node is a node of one student record from the above unsorted array. The list of student records should be sorted by student ID. (Insert function without sort function to create a linked list.) (If you insert correctly, the...

  • Read through the code of the class Player, noting it has two instance variables, name and rank, which are of type String and three further instance variables won, drew and lost which are of type int....

    Read through the code of the class Player, noting it has two instance variables, name and rank, which are of type String and three further instance variables won, drew and lost which are of type int. There is also an attribute of the class, points, which does not have a corresponding instance variable. Also note the constructor and methods of the class and what they do. TournamentAdmin class code: public class RankAdmin {    /**     * Constructor for objects of class...

  • Complete Project 4-1 as outlined above. There are no starter files for this project. You will...

    Complete Project 4-1 as outlined above. There are no starter files for this project. You will make it from scratch. You should end up with 5 files in your package (.settings, bin, src, .classpath, and .project) Console Welcome to the Customer Viewer Enter a customer number: 1003 Ronda Chavan 518 Commanche Dr. Greensboro, NC 27410 Display another customer? (y/n): Y Enter a customer number: 2439 There is no customer number 2439 in our records. Display another customer? (y/n): n Operation...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT