Fantasy Sport We would like you and your team to design, implement and test a C+
ID: 3880463 • Letter: F
Question
Fantasy Sport We would like you and your team to design, implement and test a C+ class that would be part of a Fantasy Sport Mobile App. Your class must satisty the requirements specified below and objects of your class must represent sport players NOTE: You may choose any sport you want. Requirements 1. Your class should be large enough to take about 6 hours of development. 2. Your class must make use of the following object-ariented techniques . Class Encapsulation .Overloading Operators 3. You must submit a hard copy of your UML class diagram and C++ code. 4. Teams must have two members (no exceptions) Deadline 2018 0129 diagram and code A fantasy sport is a type of online game where participants assemble imaginary or virtual teams of real players of a professional sport. These teams compete bosed on the statistical performance of those players' players in actual games. This performance is converted into points that are compiled and totaled according to a roster selected by each fantasy team's manager. In fantasy sports, team owners draft, trade and cut (drop) players, analogously to real sports.chttps://en.wilkipedia.org/wiki/Fantasy sport>Explanation / Answer
#include<fstream.h>
#include<conio.h>
#include<ctype.h>
#include<stdio.h>
#include<string.h>
#include<process.h>
#include<iostream>
using namespace std;
class cricketGame
{
char name[30];
int playerCode;
int M1R;
int M2R;
int M3R;
int total_run;
public:
cricketGame()
{playerCode=0;
strcpy(name,””);
M1R=0;
M2R=0;
M3R=0;
total_run=0;
}
void enter_name_runs() //TO TAKE ENTRY OF NEW RECORDS
{cout<<“ Enter player code(Integral) : “;
cin>>playerCode;
cout<<“ Enter player name : “;
gets(name);
cout<<“ First match run(s) : “;
cin>>M1R;
cout<<“ Second match run(s) : “;
cin>>M2R;
cout<<“ Third match run(s) : “;
cin>>M3R;
total_runs();
}
void show_record() //TO DISPLAY THE RECORDS EXISTING IN THE FILE
{cout<<“ Player code :”<<playerCode;
cout<<“ Player name : “<<name;
cout<<“ First match run(s) : “<<M1R;
cout<<“ Second match run(s) : “<<M2R;
cout<<“ Third match run(s) : “<<M3R;
cout<<“ Total run(s) : “<<total_run;
}
void total_runs() //CALCULATE TOTAL RUNS
{total_run=M1R+M2R+M3R;
}
int getplayerCode()
{return playerCode;
}
int gettotalruns()
{return total_run;
}
char* get_name()
{return name;
}
void modify_cricketGame() //TAKE DATA TO MODIFIFY EXISTING RECORD
{cout<<“ Enter new cricketGame for modification :::::::: “;
cout<<“ Enter First match run(s) : “;
cin>>M1R;
cout<<“ Enter Second match run(s) : “;
cin>>M2R;
cout<<“ Enter Third match run(s) : “;
cin>>M3R;
total_runs();
} };
cricketGame d;
fstream file;
fstream file1;
//* * * * * * * * * * CALCULATE HIGHEST RUN(s) * * * * * * * * * * * * * * * *
void highest()
{ file.open(“record.dat”,ios::in|ios::binary);
int post=0,tr=0,plr_code=0,run=0;
file.read((char*)&d,sizeof(d));
while(file)
{run=d.gettotalruns();
if(run>tr)
{post=file.tellg();
tr=run;
}
file.read((char*)&d,sizeof(d));
}file.close();
file.open(“record.dat”,ios::in|ios::binary);
file.seekg(post-sizeof(d));
file.read((char*)&d,sizeof(d));
cout<<“ ::::::::::Highest run getter cricketGame::::::::::”;
cout<<“ Highest run(s) getter code : “<<d.getplayerCode();
cout<<“ Highest run getter player is : “<<d.get_name();
cout<<“ Player total run(s) are : “<<tr;
float avg;
avg=(tr)/3;
cout<<“ Player average is : “<<avg;
file.close();
}
//* * * * * * * * * * * * INSERT NEW RECORD(s) * * * * * * * * * * * * * * * *
void insert()
{int i,no;
file.open(“record.dat”,ios::in|ios::app|ios::binary);
cout<<“ ::Entry of new record(s):: “;
cout<<“ How many record(s) you want to enter : “;
cin>>no;
for(i=1;i<=no;i++)
{d.enter_name_runs(); //insert records
file.write((char*)&d,sizeof(d));
}file.close();
}
//* * * * * * * * * * * * * DISPLAY EXISTING RECORD(s) * * * * * * * * * * * * * *
void display()
{file.open(“record.dat”,ios::in|ios::binary);
cout<<“ |||||||||||||||||||||| Entered record(s) ||||||||||||||||||||||||”;
file.read((char*)&d,sizeof(d));
while(file)
{d.show_record();
file.read((char*)&d,sizeof(d));
}file.close();
}
//* * * * * * * * * * * * * SEARCH RECORD * * * * * * * * * * * * * * * *
void search()
{int p,r,srch=0;
file.open(“record.dat”,ios::in|ios::binary);
cout<<“ Enter the player code to see his records : “;
cin>>r;
file.seekg(0);
file.read((char*)&d,sizeof(d));
while(file)
{p=d.getplayerCode();
if(r==p)
{d.show_record();
srch=1;
break;
}
else
{ file.read((char*)&d,sizeof(d));
}
}file.close();
if(srch==0)
{cout<<“ There is no record which have this playerCode .”;
}
}
//* * * * * * * * * * * * * * MODIFY DATA * * * * * * * * * * * * * * * * * *
void modify()
{int posi=0,got=0,dmd=0;
cout<<“ Enter the playerCode whose record to be modified : “;
cin>>dmd;
int ifcricketGame=1;
file.open(“record.dat”,ios::in|ios::out|ios::binary);
posi=file.tellg();
while(file)
{ file.read((char*)&d,sizeof(d));
got=d.getplayerCode();
if(dmd==got)
{file.seekg(posi);
d.modify_cricketGame();
ifcricketGame=2;
file.write((char*)&d,sizeof(d));
break;
}
posi=file.tellg();
}
file.close();
if(ifcricketGame==1)
{cout<<“ Data not available for modification “;
}
}
//* * * * * * * * * * * * * * * DELETE RECORD* * * * * * * * * * * * * * * * * * *
void delete_record()
{int pointer=0,remove_record=0,size=0,code_get=0;
// size=sizeof(file);
cout<<“ Enter the player code whose record to be deleated : “;
cin>>remove_record;
file.open(“record.dat”,ios::in|ios::out|ios::binary);
file1.open(“tempo.dat”,ios::in|ios::out|ios::binary);
file.seekg(0);
while(file)
{file.read((char*)&d,sizeof(d));
code_get=d.getplayerCode();
if(remove_record==code_get)
{cout<<” “;
}
else
{ file1.write((char*)&d,sizeof(d));
}
}file.close();
file1.close();
remove(“record.dat”);
rename(“tempo.dat”,”record.dat”);
}
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
void main()
{clrscr();
int choice;
char ans=’n’;
do
{cout<<“ =*=*=*=*=*=*=*=*=* PLAYER RECORD KEEPING SYSTEM -Animesh*=*=*=*=*=*=*=*=*=*”;
cout<<“ 1.INSERT RECORD 2.DISPLAY RCEORD 3.SEARCH RECORD 4.MODIFY RECORD 5.HIGHEST RUNS 6.DELETE PREVIOUS ENTERED RECORD 7.EXIT “;
cout<<“ Enter any one of the options : “;
cin>>choice;
switch(choice)
{case 1: insert();
break;
case 2: display();
break;
case 3: search();
break;
case 4: modify();
break;
case 5: highest();
break;
case 6: delete_record();
break;
case 7: exit(0);
break;
default: cout<<“ Enter choice between 1 to 6 “;
}
cout<<“ Do you want to choose any other option ? :(y/n): “;
cin>>ans;
clrscr();
}while(ans==’y’||ans==’Y’);
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.