(Solved Homework): using c++ code you will create a video game character management program. We will be using a vector of structs as the basic data structure to manag

using c++ code

you will create a video game character management program.

We will be using a vector of structs as the basic data structure to manage our characters.

You will need to define a struct for your character with at least 5 fields. The fields
you choose should be relevent to characters in a game that you imagine. For example:
if you imagine a futuristic fish underwater rpg.. you may have a name field, a species field,
a attack type field, an HP field and a damage field among others.

Your project will also use basic file I/O with text files. Please download and
experiment with the fileIO.zip from doc share. It contains a basic file I/O example.

When your program begins you will ask the user if they would like to load data from a file,
enter it manually or generate it randomly. Entering it manually or generating it randomly
should be similar to project 3, however the data will now be stored in a vector of structs.
If you are reading your data in from a file, you should generate the vector of structs from
the inputted file data.

After your data is inputted, the user should be able to sort from any meaningful field. Your
user should also be able to select a single character to view, modify or delete. Your user
should also be able to add characters. The user should be able to continue to sort the characters
after the data has been changed.

When done the user should be able to save the data to a file to use next time.

Expert Answer

 Couldnt sort because of lack of time. This code needs more time than 2 hours. Did everything else.

SOURCE CODE:

//Character of GTA
#include <iostream>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<fstream.h>
#include <time.h>
using namespace std;
struct rpg{
char name[50],weap[50];
int hp,ammo;
double money;
}a[50],lp[50];
void main()
{
srand (time(NULL));
int i=0;
int j,u,k,b,g;
char kl,jl;
char c=’y’;
fstream f;
f.open(“char”,ios::in|ios::binary|ios::app);
while(c==’y’)
{
cout<<“1. Load data 2. Write data 3. Random datan”;
cin>>g;
switch(g)
{
case 1:
{
while(f)
{
f.read((char*)&a[i],sizeof(rpg));
i++;
}
i–;
break;
}
case 2:
{
aman:
cout<<“Enter name,name of weapon,health points,ammo,moneyn”;
gets(a[i].name);gets(a[i].weap);cin>>a[i].hp>>a[i].ammo>>a[i].money;
break;
}
case 3:
{
for(u=0;u<10;u++)
{
k = rand() % (122-97+1) + 97;
kl=k;
j=rand() % (122-97+1) + 97;
jl=j;
a[i].name[u]=kl;
a[i].weap[u]=jl;
}
a[i].hp=rand()%100+1;
a[i].ammo=rand()%1000+1;
a[i].money=rand()%10000+1;
break;
}
default:
{
cout<<“Wrong choice”;
break;
}
}
cout<<“Do you want more character(y or n)”;
cin>>c;
i++;
}
int ql=0,v;
char gh[50];
int bb;
double cc;
int yon;
int am,an,d,ee;
int kk=0,ll;
char ch=’y’;
for(;ch==’y’;)
{
cout<<“1. View characters 2. Select to view, modify, details details 3. Add characters 4. Save”;
cin>>v;
switch(v)
{
case 1:
{
cout<<“nCharNumtNametNameofWeapontHealthPointstAmmotMoneyn”;
for(;ql<i;ql++)
{
cout<<“#”<<ql+1<<“. t”;
puts(a[ql].name);cout<<“tt”;
puts(a[ql].weap);cout<<“t”;
cout<<“ttt”<<a[ql].hp<<“tt”<<a[ql].ammo<<“t”<<a[ql].money<<“nn”;
}
break;
}
case 2:
{
clrscr();
cout<<“Enter character number”;
cin>>b;
b–;
cout<<“#”<<b+1<<“. t”;
puts(a[b].name);cout<<“tt”;
puts(a[b].weap);cout<<“t”;
cout<<“ttt”<<a[b].hp<<“tt”<<a[b].ammo<<“t”<<a[b].money<<“nn”;
cout<<“1. Modify 2.Delete”;
cin>>kk;
switch(kk)
{
case 1:
{
cout<<“What to modify 1. Name 2. Name of weapon 3. Health point 4. Ammo 5. Money”;
cin>>ll;
switch(ll)
{
case 1:
{
cout<<“Enter name”;
gets(gh);
strcpy(a[b].name,gh);
break;
}
case 2:
{
cout<<“Enter name of weapon”;
gets(gh);
strcpy(a[b].weap,gh);
break;
}
case 3:
{
cout<<“Enter HP”;
cin>>bb;
a[b].hp=bb;
break;
}
case 4:
{
cout<<“Enter Ammo”;
cin>>bb;
a[b].ammo=bb;
break;
}
case 5:
{
cout<<“Enter Money”;
cin>>cc;
a[b].money=cc;
break;
}
default:
{
cout<<“Wrong choice”;
break;
}
}
break;
}
case 2:
{
cout<<“Are you sure you want to delete 1 for yes 2 for no”;
cin>>yon;
if(yon==1)
{

for(am=0,an=0;an<i;am++,an++)
{
if(an==b){am–; continue;}
strcpy(lp[am].name,a[an].name);
strcpy(lp[am].weap,a[an].weap);
lp[am].ammo=a[an].ammo;
lp[am].money=a[an].money;
lp[am].hp=a[an].hp;

}
strcpy(a[i].name,””);
a[i].ammo=0;
a[i].money=0;
a[i].hp=0;
i–;
for(am=0;am<i;am++)
{
if(an==d){am–; continue;}
strcpy(a[an].name,lp[am].name);
strcpy(a[an].weap,lp[am].weap);
a[an].ammo=lp[am].ammo;
a[an].money=lp[am].money;
a[an].hp=lp[am].hp;

}
}
break;
}
default:
{
cout<<“Wrong choice”;
break;
}
}
break;
}

case 3:
{
goto aman;
break;
}
case 4:
{
for(ee=0;ee<i;ee++)
{
f.write((char*)&a[ee],sizeof(rpg));
}
break;
}
default:
{
cout<<“Wrong choice”;
break;
}
}
cout<<“do you want to start again(y or n)”;
cin>>ch;
}
getch();
}

Screenshots:

iWriteHomework
Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Professional and Experienced Academic Writers

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents