Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ex03_13.cpp &&Ex03_15.cpp #112

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions 201816040221/Ex03_13/Ex03_13.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
//#include
using namespace std;

#include "Invoice.h" // include definition of class Employee

// function main begins program execution
int main()
{
string a,b;
int x,y;
cout<<"请输入相关量";
cin>>a;
cin>>b;
cin>>x;
cin>>y;
Invoice Invoice1(a,b,x,y);

cout<<Invoice1.getInvoicePd()<<" "<<Invoice1.getInvoicePN()<<" "<<Invoice1.getInvoiceprice()<<" "<<Invoice1.getInvoicesales()<<" "<<Invoice1.InvoiceAmount(x,y);
int sales,price;
//cout<<"现在的情况:";





}
61 changes: 61 additions & 0 deletions 201816040221/Ex03_13/Invoice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Lab 3: Employee.cpp
// Employee class member-function definitions.
#include <iostream>
#include <iomanip>
#include <stdexcept>
#include "Invoice.h"
using namespace std;

Invoice::Invoice(string PN,string Pd,int sales,int price)//declar the Invoice member
{
setInvoicePN(PN);
setInvoicePd(Pd);
setInvoicesales(sales);
setInvoiceprice(price);

}
void Invoice::setInvoicePN(string PN)//declar the PN member
{
InvoicePN=PN;
}
string Invoice::getInvoicePN()
{
return InvoicePN;
}
void Invoice::setInvoicePd(string Pd)//declar the Pd member
{
InvoicePd=Pd;
}
string Invoice::getInvoicePd()
{
return InvoicePd;
}
void Invoice::setInvoicesales(int sales)//declar the sales memver
{
Invoicesales=sales;
}
int Invoice::getInvoicesales()
{
return Invoicesales;
}
void Invoice::setInvoiceprice(int price)//declar the price member
{
Invoiceprice=price;
}
int Invoice::getInvoiceprice()
{
return Invoiceprice;
}
int Invoice::InvoiceAmount(int sales,int price)//declar the InvoiceAmount member
{
if(sales==0||price==0)
{
InvoiceAmount1=0;
}
else
{
InvoiceAmount1=sales*price;
}

return InvoiceAmount1;
}
29 changes: 29 additions & 0 deletions 201816040221/Ex03_13/Invoice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Lab 3: Employee.h
// Employee class definition.

#include <string> // program uses C++ standard string class
using namespace std;
//#define INVOIE_H
// Employee class definition
class Invoice
{
public://declar the three public member

Invoice(string,string,int,int);
void setInvoicePN(string);
void setInvoicePd(string);
void setInvoicesales(int);
void setInvoiceprice(int);
string getInvoicePN();
string getInvoicePd();
int getInvoicesales();
int getInvoiceprice();
int InvoiceAmount(int,int);

private:
string InvoicePN;
string InvoicePd;
int Invoicesales;
int Invoiceprice,InvoiceAmount;
/
}; // end class Invoice
51 changes: 51 additions & 0 deletions 201816040221/Ex03_15/Date.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Lab 3: Employee.cpp
// Employee class member-function definitions.
#include <iostream>
#include <iomanip>
#include <stdexcept>
#include "Date.h"
using namespace std;
Date::Date(int month,int day,int year)//declare three date members
{
setDatemonth(month);
setDateday(day);
setDateyear(year);

}
void Date::setDatemonth(int month)//declar the month member
{
if(month<1||month>12)
{
Datemonth=1;
}
else
{


Datemonth=month;
}
}
int Date::getDatemonth()
{

return Datemonth;
}
void Date::setDateday(int day)//declar the day member
{

Dateday=day;
}
int Date::getDateday()
{
return Dateday;
}
void Date::setDateyear(int year)
{
Dateyear=year;
}
int Date::getDateyear()
{
return Dateyear;
}


29 changes: 29 additions & 0 deletions 201816040221/Ex03_15/Date.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Lab 3: Employee.h
// Employee class definition.

#include <string> // program uses C++ standard string class
using namespace std;
//#define INVOIE_H
// Employee class definition
class Date
{
public://declar the three public member

Date(int,int,int);
void setDatemonth(int);
void setDateday(int);
void setDateyear(int);


int getDatemonth();
int getDateday();
int getDateyear();


private:
int Datemonth;
int Dateday;
int Dateyear;
int dissplayDate1();

}; // end class date
29 changes: 29 additions & 0 deletions 201816040221/Ex03_15/Ex03_15.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Lab 3: EmployeeTest.cpp
// Create and manipulate two Employee objects.
#include <iostream>
//#include
using namespace std;

#include "Date.h" // include definition of class Employee

// function main begins program execution
int main()
{

int a,x,y;
cout<<"ÇëÊäÈëÏà¹ØÁ¿\n";
cin>>a;
cin>>x;
cin>>y;
Date Date1(a,x,y);

//cout<<Date1.displayDate(a,x,y);
int sales,price;
cout<<Date1.getDatemonth()<<"/"<<Date1.getDateday()<<"/"<<Date1.getDateyear();
}