Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //3.13
- void displayAccount(Account accountToDisplay) {
- cout << accountToDisplay.getName() << "Balance is $" << accountToDisplay.getBalance();
- }
- int main() {
- Account accA{ "Jane Green", 58};
- Account accB{ "Jogn Blue", 85};
- displayAccount(accA);
- }
- //3.12
- class Date {
- public:
- Date ( int iday, int imonth, int iyear) {
- day = iday;
- month = imonth;
- year = iyear;
- }
- //set day
- void setDay(int iday) {
- day = iday;
- }
- //set month
- void setMonth(int imonth) {
- month = imonth;
- }
- //set year
- void setYear(int iyear) {
- year = iyear;
- }
- // get day
- int getDay()const {
- return day;
- }
- //get month
- int getMonth() {
- return month;
- }
- //get year
- int getYear() {
- return year;
- }
- private:
- int day;
- int month;
- int year;
- };
- int main() {
- Date itemtest (2, 5, 12);
- cout << "The date is: " << itemtest.getDay() << "/" << itemtest.getMonth() << "/" << itemtest.getYear();
- }
- //3.10
- class Invoice {
- public:
- Invoice(string partnumber, string partdescription, int quantity, int priceperitem) {
- partnum = partnumber;
- partdesc = partdescription;
- quant = quantity;
- price = priceperitem;
- }
- //setter for partnum
- void setPartnum(string partnumber) {
- partnum = partnumber;
- }
- //setter for partdesc
- void setPartdesc(string partdescription) {
- partdesc = partdescription;
- }
- //setter for quant
- void setQuant(int quantity) {
- quant = quantity;
- }
- //setter for price
- void setPrice(int priceperitem) {
- price = priceperitem;
- }
- //getter for quant
- int getQuant() const {
- return quant;
- }
- //getter for price
- int getPrice()const {
- return price;
- }
- //getter for partnum
- string getPartnum()const {
- return partnum;
- }
- //getter for partdesc
- string getPartdesc()const {
- return partdesc;
- }
- //getter of invoice
- int getInvoiceAmount() {
- if (quant < 0) {
- quant = 0;
- }
- else if (price < 0) {
- price = 0;
- }
- return quant*price;
- }
- private:
- string partnum, partdesc;
- int quant, price;
- };
- int main() {
- Invoice testItem( "GTX1080", "GPU", 10, 700);
- cout <<"\n Part Number: " << testItem.getPartnum() << endl;
- cout << "\n Part Description: " << testItem.getPartdesc() << endl;
- cout << "\n Quantity: " << testItem.getQuant() << endl;
- cout << "\n Price Per item: " << testItem.getPrice() << endl;
- cout << "\n Invoice Amount: $" << testItem.getInvoiceAmount() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement