C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 4th, 2012, 07:31 PM
Juice24 Juice24 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 Juice24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 14 sec
Reputation Power: 0
First time using a class, kinda stuck

This is my first time using classes and constructors/destructors. Does anybody see what Im doing wrong here?

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

using namespace std;


class menuItemType
{

public:

menuItemType();
~menuItemType();
void accessData();

public:
string itemName;
double itemCost;
void getData(menuItemType item[], ofstream& outData);
void showMenu(menuItemType item[], ofstream& outData);
void printCheck (double& total, double& tax, double& totalF, ofstream& outData);

};

menuItemType :: menuItemType()
{
menuItemType item[8];
ofstream outData;
getData(item, outData);
}
menuItemType :: ~menuItemType()
{
&menuItemType:rintCheck;
}

void menuItemType :: accessData()
{
&menuItemType::showMenu;

}

void menuItemType :: getData(menuItemType item[], ofstream& outData)
{
int i=0;
ifstream inData;
inData.open("InMenu.txt");
cout << fixed << setprecision(2);
outData << fixed << setprecision(2);


while(!inData.eof())
{
inData >> item[i].itemName >> item[i].itemCost;
++i;
}

}
;
void menuItemType :: showMenu(menuItemType item[],ofstream& outData)
{
int choice = 0;
double total = 0.0, totalF = 0.0, tax = 0.0;
char exit = 'y';
int j = 1, z = 1, i = 1;

for (int i=0; i< 8; i++)
{
cout << j << ". " << setw(18) << left << item[i].itemName << "$" << setw(10) << item[i].itemCost << endl;
outData << j << ". " << setw(18) << left << item[i].itemName << "$" << setw(10) << item[i].itemCost << endl;
j++;

}

cout << endl;

while(exit == 'y' || exit == 'Y')
{

cout << "Please Enter your Selection or 0 to Exit : ";
cin >> choice;

if(cin.fail())
{
cout << "~~~~~~~~~Invalid selection~~~~~~~~~" << endl;
cin.clear();
cin.ignore(1000,'\n');
}
else if (choice==0) {break;}
else
{
choice--;
total += (item[choice].itemCost);
tax = (total * .05);
totalF = total + tax;
cout << endl;
outData << endl;
}
cout << endl;
outData << endl;

cout << item[choice].itemName << " " << item[choice].itemCost << endl;
cout << "================================================== ====" << endl;
cout << "Do you want to continue (Y/N): ";
outData << item[choice].itemName << " " << item[choice].itemCost << endl;
outData << "================================================== ====" << endl;
outData << "Do you want to continue (Y/N): ";
cin >> exit;

}
printCheck(total, tax, totalF, outData);
}

void menuItemType :: printCheck(double& total, double& tax, double& totalF, ofstream& outData)
{
cout << "\n\nThanks for Dinning With Us!" << endl;
cout << "<><><><><><><><><><><><><><>\n" << endl;
cout << "Customer Receipt " << endl;
cout << "SubTotal: $" << total <<endl;
cout << "Tax: $" << tax << endl;
cout << " -----" << endl;
cout << "Total: $" << totalF << endl;
cout << "Please Come Again!" << endl;

outData << "\n\nThanks for Dinning With Us!" << endl;
outData << "<><><><><><><><><><><><><><>\n" << endl;
outData << "Customer Receipt " << endl;
outData << "SubTotal: $" << total <<endl;
outData << "Tax: $" << tax << endl;
outData << " -----" << endl;
outData << "Total: $" << totalF << endl;
outData << "Please Come Again!" << endl;
}

int main()
{
//menuItemType myMenu;



ofstream outData;
outData.open("OutMenu.txt");


cout<< " Welcome! "
cout<< "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout<< " *To select an Item from the list below, " << endl;
cout<< "just indicate the Item number for the item \n\n" << endl;

outData << " Welcome! " << endl;
outData << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
outData << " *To select an Item from the list below, " << endl;
outData<< "just indicate the Item number for the item \n\n" << endl;

menuItemType menu;
menu.accessData();

&menuItemType::getData;
&menuItemType::showMenu;


menuItemType();



system("pause");

return 0;

}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > First time using a class, kinda stuck


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap