Stuck on a problem

I have been given an assignment and i dont know how to write the code for it. Most of the code written below was given to us by our tutor, the problem is I dunno how to add and update a new stock item, can some please help me i will be eternally grateful
// ProjCarStock.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <conio.h>
#include <iomanip>
#include <string>
#include <ctype.h>
#include <fstream>

using namespace std;



struct carStock
{
int carStockNo; //autimatically assigned ascending from 1000
char model[26]; // between 3 - 25 chars
char make; // A - Audi, M - Mercedes, V - VolksWagon, F - Ford
char regNo[9]; // 8 chars at least 1 number / 2 digits
double costPrice; // £250 -- £20000
double sellingPrice; // £450 -- £27000
};



//Prototypes -common functions
void press_key(HANDLE hdl, int col, int row);
void message(HANDLE hdl, char mess[], int col, int row);
char again(HANDLE hdl, int col, int row);
void set_menu(HANDLE hdl );
int get_option(HANDLE hdl, int c , int r , int min , int max);
void gotoXY( HANDLE hdl, SHORT x, SHORT y );


int createArray(HANDLE hdl, struct carStock cars[ ]);
void menu(HANDLE hdl);

void display (HANDLE hdl, struct carStock cars[ ], int size);// Display all
void displayCat (HANDLE hdl, struct carStock cars[ ], int size);// Display by regNo
void add (HANDLE hdl, struct carStock cars[ ], int & size);// Add carStockDetails
void update (HANDLE hdl, struct carStock cars[ ], int size);// Update carStockDetails
void getscreen (HANDLE hdl, char name[]);
void toUpperCase (char s1[]);
void toLowerCase (char s1[]);
void carStockHeading(HANDLE hdl); //Headings


int _tmain(int argc, _TCHAR* argv[])
{
// insert HANDLE hdl
HANDLE hdl = GetStdHandle( STD_OUTPUT_HANDLE );

struct carStock cars[25];
int size;
int option;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

size = createArray(hdl, cars);
do
{
menu(hdl);
option = get_option(hdl, 1,5,45,17);
switch ( option )// Menu Options
{
case 1 : display(hdl, cars, size);break;
case 2 : displayCat(hdl, cars, size);break;
case 3 : add(hdl, cars, size);break;
case 4 : update(hdl, cars, size);break;
}

}while(option !=5);

return 0;
}

void update (HANDLE hdl, struct carStock cars[ ], int size)//update carStock details
{
int x, option;
int no;
bool found = false;

getscreen(hdl, "UpdateCarScreen.txt");

// Enter carStock No.
gotoXY(hdl, 41,4);cin >> no;
for(x=0;x<size;x++)
{
// complete code
}
}

void add (HANDLE hdl, struct carStock cars[ ], int & size)//add carStock details
{

system("cls");
gotoXY(hdl, 10, 1); cout<<"Adding new stock";

int carStockNo;
char model[26];
char make;
char reg[8];
double costPrice;
double sellingPrice;

gotoXY(hdl, 10,5); cout<<"Enter the model of the car";
gotoXY(hdl, 14,6); cin>>model;
gotoXY(hdl, 10,7); cout<<"Enter the make of the car";
gotoXY(hdl, 14,8); cin>>make;
gotoXY(hdl, 10,9); cout<<"Enter the registration number";
gotoXY(hdl, 14,10);cin>>reg;
gotoXY(hdl, 10,11);cout<<"Enter the cost of the car";
gotoXY(hdl, 14,12);cin>>costPrice;
gotoXY(hdl, 10,13);cout<<"Enter the selling price of the car";
gotoXY(hdl, 14,14);cin>>sellingPrice;

_getche();
return;


}

void displayCat (HANDLE hdl, struct carStock cars[ ], int size)// display carStock details by regNo
{
int x;
int page=0;
char cat[2];
system("cls");

//complete code
press_key(hdl, 1,26);
}

void display (HANDLE hdl, struct carStock cars[ ], int size)//display all carStock details
{
int x;
int page=0;

carStockHeading(hdl );
for(x=0;x<size;x++)
{
cout << "\n" << setw(6) << cars[x].carStockNo << setw(28) << cars[x].model << setw(12) << cars[x].make
<< setw(10) << cars[x].regNo << setw(10) << cars[x].costPrice << setw(10) << cars[x].sellingPrice;
page++;
if(page == 10)
{

if(x < (size - 1))
{
press_key(hdl, 1,26);
carStockHeading(hdl );
}
page=0;
}
}
press_key(hdl, 1,26);
}

void carStockHeading(HANDLE hdl)//headings
{
system("cls");
cout << "\n\n Car Stock Details \n\n";
cout << setw(12) << "carStock No." << setw(20) << "model" << setw(12) << "Make"
<< setw(10) << "regNo" << setw(10) << "Cost" << setw(13) << " Selling Price";
}

void getscreen (HANDLE hdl, char name[])
{
ifstream in;
char ch;
in.open(name);

system("cls");

while ( !in.eof())
{
ch = in.get();
if (in.good())
cout << ch;
}
in.close();
}

int createArray(HANDLE hdl, struct carStock cars[ ] )
{
//Existing carStock Details
cars[0].carStockNo=1000; strcpy_s( cars[0].model,"Mondeo "); cars[0].make= 'F';
strcpy_s(cars[0].regNo, "TUI 1134"); cars[0].costPrice= 1100; cars[0].sellingPrice = 3500;

cars[1].carStockNo= 1001; strcpy_s(cars[1].model, "TT");cars[1].make= 'A';
strcpy_s(cars[1].regNo, "CDG 11"); cars[1].costPrice= 6000; cars[1].sellingPrice = 9000;

return 2;
}

void toUpperCase (char s1[]) //Change to Upper Case
{
for(int x=0; x < strlen(s1); x++)
{
s1[x] = toupper(s1[x]);
}

}

void toLowerCase (char s1[]) //Change to Lower Case
{
for(int x=0; x < strlen(s1); x++)
{
s1[x] = tolower(s1[x]);
}
}



void menu(HANDLE hdl)
{
system("cls");
gotoXY(hdl, 10,1); cout << "******* Insert your company name here *******";

gotoXY(hdl, 10,5); cout << "1. Display car Stock Details (ALL)";
gotoXY(hdl, 10,7); cout << "2. Display car Stock Details (By Make)";
gotoXY(hdl, 10,9); cout << "3. Add car Stock Details";
gotoXY(hdl, 10,11); cout << "4. Update car Stock Details";
gotoXY(hdl, 10,13); cout << "5. Exit";
gotoXY(hdl, 10,17); cout << "Which Option ( 1-5) [_]";


}

int get_option(HANDLE hdl, int min, int max, int col, int row)
{
int x;
do
{
gotoXY(hdl, col, row); cout << "_";
gotoXY(hdl, col, row); cin >> x;
if ( x < min || x > max)
message(hdl ,"Invalid Menu Option", 30,23);
}while ( x<min || x > max);
return x;
}

void press_key( HANDLE hdl, int col, int row)
{
gotoXY(hdl, col,row);
cout << "Press Key ";
_getche();

}

void message(HANDLE hdl, char message[], int col, int row)
{
int x;
gotoXY(hdl, col,row);
cout << message;
press_key(hdl, col,row+1);
gotoXY(hdl, col,row);
for( x=0; x < strlen(message) ; x++)
cout << " ";
gotoXY(hdl, col,row+1);
cout << " ";
}

char again(HANDLE hdl, int col, int row)
{
char ch;
gotoXY(hdl, col,row); ch = _getche();
ch = toupper(ch);
while( ch !='Y' && ch !='N')
{
message(hdl,"Must Enter Y or N", 30,23);
gotoXY(hdl, col,row); cout << "_";
gotoXY(hdl, col,row); ch = _getche();
ch = toupper(ch);

}
return ch;
}

void gotoXY( HANDLE hdl, SHORT x, SHORT y )
{
// Set the cursor position.
COORD Cord;
Cord.X = x;
Cord.Y = y;
SetConsoleCursorPosition( hdl, Cord );
}


Topic archived. No new replies allowed.