Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Untitled document - Google Docs

1 answer below »
Untitled document - Google Docs
Answered 4 days After Jun 19, 2021

Solution

Yohansh answered on Jun 24 2021
158 Votes
assessement 86793/Documentation of 86793.docx
Introduction of the Assessment
This assessment mainly focus on the implementation of basic Object oriented programming concepts. It say to store the name and average score of the 12 players in an a
ay , by creating a different data type which contains first name ,last name and average score of the player and sort them according to decreasing average score.
Requirements specifications of the assignment
1)Knowledge class and objects.
2)How to implement quicksort.
3) Implementation of swapping .
4)How to create a header file.
Source Code
Player.h
#pragma once
using namespace std;
class player{
private:
    string firstName;
    string lastName;
    double average;
public:
    
sette
    void setPlayer(string first,string last, double averg)
    {
        firstName=first;
        lastName=last;
        average=averg;
    }

Gette
string getName() {
return (firstName+" "+lastName);
}
    double getAverage(){
    return average;
}
};
void displayTeam();
void insert(string first,string last, double score);
void swap(player *a, player *b);
void sort();
Player.cpp
#include #include #include "player.h"
using namespace std;
const int size=12;
int index=0;
player a
[size]={};
void displayTeam()
    {
        for(int i=0;i<12;i++)
        {
            cout
a
[i].getName()
" "
a
[i].getAverage()
endl;
        }
    }
void insert(string first,string last, double score)
{
    player temp;
    temp.setPlayer(first,last,score);
    a
[index++]=temp;
}
void swap(player *a, player *b)
{
    player temp=*a;
    *a=*b;
    *b=temp;
}
int partition ( int low, int high)
{
double pivot = a
[high].getAverage();
int i = (low - 1);
for (int j = low; j <= high- 1; j++)
{
if (a
[j].getAverage() >= pivot)
{
i++;
swap(&a
[i], &a
[j]);
}
}
swap(&a
[i + 1], &a
[high]);
return (i + 1);
}

void quickSort( int low, int high)
{
if (low < high)
{

int pi = partition( low, high);
quickSort(low, pi - 1);
quickSort(pi + 1, high);
}
}

void sort()
{
quickSort(0, 11);
}
Playertest.cpp
#include #include #include "player.h"
using namespace std;
int main()
{
insert("Ram","Gupta",79.3);
    insert("Shayam","Singh",85.8);
    insert("Lalan","Maken",65.3);
    insert("Ashish","Tripathi",95.9);
    insert("Raj", "Jaiswal", 76.0);
    insert("Yash","Shrivastav",59.6);
    insert("Ayush","Gupta",...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here