Question
Can you please fix my code that is not running? In Visual Studio 2012 Supply.H #ifndef SUPPLY_H #define SUPPLY_H #include #include #include using namespace std;
Can you please fix my code that is not running? In Visual Studio 2012
Supply.H
#ifndef SUPPLY_H
#define SUPPLY_H
#include
#include
#include
using namespace std;
using namespace System;
using namespace System::IO;
using namespace System::Windows::Forms;
using namespace System::Runtime::InteropServices;
class Supply
{
public:
Supply();
void ListRecords( char *);
void IntsertItem( int, char [], double, Supply* );
int CountItems();
int GetInventoryNumber() const;
char* GetGoldfishType() const;
double GetPrice() const;
Supply* GetLink() const;
void SetInventoryNumber ( int );
void SetGoldfishType( char []);
void SetPrice ( double );
void SetLink ( Supply* );
private:
int InventoryNumber;
double Price;
mutable char GoldfishType [25];
Supply* NextRecordPointer;
};
#endif
Supply.Cpp
#include "stdafx.h"
#include "Supply.h"
Supply * FirstRecordPointer;
Supply::Supply()
{
InventoryNumber = 0;
GoldfishType[24] = '\0';
Price = 0;
NextRecordPointer = NULL;
}
void Supply::ListRecords ( Char * ReportName )
{
ofstream OutputFile;
Supply * CurrentRecordPointer;
char Separator[60] = "____________________________________________________________";
OutputFile.open((char*)(void*)Marshal::StringToHGlobalAnsi(string::Concat(Directory::GetCurrentDirectory(),
"\\SupplyFileForOutput.txt")));
if (!OutputFile)
{
Application::Exit();
return;
}
OutputFile << endl << Separator << endl << endl;
OutputFile << setw(38) << setfill (' ') << ReportName << endl;
OutputFile << Separator;
OutputFile << endl << endl << setw(15) << setfill(' ') << "Identification"
OutputFile << setw(16) << setfill (' ') << "Type Of"
OutputFile << setw(19) << setfill (' ') << "Price" << endl
OutputFile << setw(11) << setfill (' ') << "Number"
OutputFile << setw(21) << setfill (' ') << "Goldfish"
<< endl << Separator << endl << Separator << endl;
CurrentRecordPointer = FirstRecordPointer;
while ( CurrentRecordPointer != NULL)
{
OutputFile << endl;
OutputFile << right;
OutputFile << << endl << setw(9) << setfill (' ')
<< CurrentRecordPointer->GetInventoryNumber();
OutputFile << setw(28) << setfill(' ')
<< CurrentRecordPointer->GetGoldfishType();
OutputFile << fixed << showpoint << setprecision(2)
<< set(8) << setfill(' ')
<< " $ " << CurrentRecordPointer->GetPrice();
CurrentRecordPointer = CurrentRecordPointer->GetLink();
}
OutputFile << endl << Separator << endl;
OutputFile.close();
return;
}
void Supply::InsertItem (int InitInventoryNumber, char InitGoldfishType[], double InitPrice, Supply* CurrentRecordPointer)
{
Supply* CurrentPointer;
Supply* TrailPointer;
bool Found;
InventoryNumber = InitInventoryNumber;
strcpy_s (GoldfishType, InitGoldfishType);
Price = InitPrice;
if (FirstRecordPointer == NULL)
{
FirstRecordPointer = CurrentRecordPointer;
}
else
{
CurrentPointer = FirstRecordPointer;
Found = false;
while ( CurrentPointer != NULL && !Found)
{
if (CurrentPointer->InventoryNumber >=InitInventoryNumber)
{
Found = true;
}
else
{
TrailPointer = CurrentPointer;
CurrentPointer = CurrentPointer->GetLink();
}
}
if (CurrentPointer == FirstRecordPointer)
{
NextRecordPointer = FirstRecordPointer;
FirstRecordPointer = CurrentRecordPointer;
}
else
{
TrailPointer->NextRecordPointer = CurrentRecordPointer;
NextRecordPointer = CurrentPointer;
}
}
}
int Supply::CountItems()
{
Supply* CurrentRecordPointer;
int ItemCounter = 0;
for (CurrentRecordPointer = FirstRecordPointer;
CurrentRecordPointer = != NULL;
CurrentRecordPointer = CurrentRecordPointer->GetLink() )
{
ItemCounter++;
}
return ( ItemCounter);
}
int Supply::GetInventoryNumber() const
{
return ( InventoryNumber );
}
char* Supply::GetGoldfishType() const
{
return (GoldfishType);
}
double Supply::GetPrice() const
{
return(Price);
}
Supply* Supply::GetLink() const
{
return NextRecordPointer;
}
void Supply::SetInventoryNumber ( int InitInventoryNumber)
{
InventoryNumber = InitInventoryNumber;
}
void Supply::SetGoldfishType ( char InitGoldfishType[])
{
strcpy_s (GoldfishType, InitGoldfishType);
}
void Supply::SetPrice( double InitPrice)
{
Price = InitPrice;
}
void Supply::SetLink(Supply* InitLink)
{
NextRecordPointer = InitLink;
}
GoldfishFileForInput.txt
110 Ranchu 129.99 210 Comet 002.99 310 Chocolate Oranda 016.99 410 Shubunkin 005.99 510 Calico Pearlscale 049.99
stdafx.h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently #pragma once
// TODO: reference additional headers your program requires here
#include "Supply.h" extern Supply* FirstRecordPointer;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started