header file:
#include <string>
using std::string;
class Invoice
{
private:
string PartNumber;
string PartDescription;
int Quantity;
int PricePerItem;
int InvoiceAmount;
public:
Invoice(string, string, int, int);
void setInitial(string, string, int, int);
void setPartNum(string);
void setPartDescription (string);
void setQuantity(int);
void setPricePerItem(int);
string getPartNumber();
string getPartDescription();
int getQuantity();
int getPricePerItem();
int getInvoiceAmount();
}Main code for the library#include <iostream>
using std::cout;
using std::endl;
#include <string>
using std::string;
#include "Invoice.h"
[B]Invoice::Invoice(string part, string description, int number, int money)
{
setInitial(part, description, number, money);
}[/B]
void Invoice::setInitial(string part, string description, int number, int money)
{
PartNumber = part;
PartDescription = description;
Quantity = number;
PricePerItem = money;
}
void Invoice::setPartNum(string part)
{
PartNumber = part;
}
void Invoice::setPartDescription(string description)
{
PartDescription = description;
}
void Invoice::setQuantity(int number)
{
if (number >= 0)
Quantity = number;
if (number < 0)
{
cout << "quanity cannot be negative.\n";
cout << "quanity set to 0\n";
Quantity = 0;
}
}
void Invoice::setPricePerItem(int money)
{
if (money >= 0)
PricePerItem = money;
if (money < 0)
{
cout << "pricePerItem cannot be negative.\n";
cout << "pricePerItem set to 0\n";
PricePerItem =0;
}
}
string Invoice::getPartNumber()
{
return PartNumber;
}
string Invoice::getPartDescription()
{
return PartDescription;
}
int Invoice::getQuantity()
{
return Quantity;
}
int Invoice::getPricePerItem()
{
return PricePerItem;
}
int Invoice::getInvoiceAmount()
{
if ((Quantity * PricePerItem) >= 0 )
{
InvoiceAmount = Quantity * PricePerItem;
return InvoiceAmount;
}
if (Quantity < 0 )
{
return 0;
}
if (PricePerItem < 0)
{
return 0;
}
}


Sign In
Create Account

Back to top









