Untitled document - Google Docs

1 answer below »
pfa


Untitled document - Google Docs
Answered 4 days AfterJun 19, 2021

Answer To: Untitled document - Google Docs

Yohansh answered on Jun 24 2021
140 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 array , by c
reating 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:
    //setter
    void setPlayer(string first,string last, double averg)
    {
        firstName=first;
        lastName=last;
        average=averg;
    }
// Getter
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 arr[size]={};
void displayTeam()
    {
        for(int i=0;i<12;i++)
        {
            cout<        }
    }
void insert(string first,string last, double score)
{
    player temp;
    temp.setPlayer(first,last,score);
    arr[index++]=temp;
}
void swap(player *a, player *b)
{
    player temp=*a;
    *a=*b;
    *b=temp;
}
int partition ( int low, int high)
{
double pivot = arr[high].getAverage();
int i = (low - 1);
for (int j = low; j <= high- 1; j++)
{
if (arr[j].getAverage() >= pivot)
{
i++;
swap(&arr[i], &arr[j]);
}
}
swap(&arr[i + 1], &arr[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