diff --git a/201816040319/Ex03_13/Ex03_13.cpp b/201816040319/Ex03_13/Ex03_13.cpp new file mode 100644 index 0000000..d169a4e --- /dev/null +++ b/201816040319/Ex03_13/Ex03_13.cpp @@ -0,0 +1,37 @@ +// github 3.13 +// Invoice class definition. + +#include +using namespace std; + +#include "Invoice.h" // include definition of class Invoice + +// function main begins program execution +int main() +{ + string Number; + string Style; + int Sell; + int Price; + + cout <<"零件号:"<>Number; + cout <<"零件描述:"<>Style; + cout <<"销售总量:"<>Sell; + cout <<"单价:"<>Price; + + Invoice invoice(Number,Style,Sell,Price); + + cout <<"验证数据:"< +using namespace std;Invoice + +#include "Invoice.h" // Invoice class definition + + +Invoice::Invoice(string number,string style ,int sell ,int price ) +{ + setInvoiceNumber(number); + setInvoiceStyle(style); + setInvoiceSell(sell); + setInvoicePrice(price); + +} + //Number + void Invoice::setInvoiceNumber(string Number) + { + number=Number; + } + string Invoice::getInvoiceNumber() + { + return number; + } + + //style + void Invoice::setInvoiceStyle(string Style) + { + style=Style; + } + string Invoice::getInvoiceStyle() + { + return style; + } + + //Sell + void Invoice::setInvoiceSell(int Sell) + { + if(Sell<=0) + sell=0; + else + sell=Sell; + } + int Invoice::getInvoiceSell() + { + return sell; + } + //price + void Invoice::setInvoicePrice(int Price) + { + if(Price<=0) + price=0; + else + price=Price; + } + int Invoice::getInvoicePrice() + { + return price; + } + //Ammount + int Invoice::getInvoiceAmmount() + { + return sell*price; + } diff --git a/201816040319/Ex03_13/Invoice.h b/201816040319/Ex03_13/Invoice.h new file mode 100644 index 0000000..8c33d72 --- /dev/null +++ b/201816040319/Ex03_13/Invoice.h @@ -0,0 +1,29 @@ +// github 3.13 +// Invoice class definition. + +#include // program uses C++ standard string class +using namespace std; + +// Invoice class definition +class Invoice +{ +public: + Invoice(string number ,string style ,int sell ,int price ); + + void setInvoiceNumber(string Number); + string getInvoiceNumber(); + void setInvoiceStyle(string Style); + string getInvoiceStyle(); + void setInvoiceSell(int Sell); + int getInvoiceSell(); + void setInvoicePrice(int Price); + int getInvoicePrice(); + int getInvoiceAmmount(); + +private: + string number; + string style; + int sell ; + int price; + +}; // end class Invoice diff --git a/201816040319/Ex03_15/Date.cpp b/201816040319/Ex03_15/Date.cpp new file mode 100644 index 0000000..2b9bd26 --- /dev/null +++ b/201816040319/Ex03_15/Date.cpp @@ -0,0 +1,49 @@ + +// Date class member-function definitions. +#include +using namespace std; + +#include "Date.h" // Date class definition + +Date::Date(int month,int day,int year) +{ + + setDateMonth(month); + setDateDay(day); + setDateYear(year); +} +//Year +void Date::setDateYear(int Year) +{ + year=Year; +} +int Date::getDateYear() +{ + return year; +} +//Month +void Date::setDateMonth(int Month) +{ + if(Month>=13) + month=1; + else + month=Month; +} +int Date::getDateMonth() +{ + return month; +} +//Day +void Date::setDateDay(int Day) +{ + day=Day; +} +int Date::getDateDay() +{ + return day; +} + +void Date::getdisplayDate( ) +{ + cout<<"month/day/year:"< // program uses C++ standard string class +using namespace std; + +// Date class definition +class Date +{ +public: + Date(int year,int month,int day); + + void setDateYear(int Year); + int getDateYear(); + void setDateMonth(int Month); + int getDateMonth(); + void setDateDay(int Day); + int getDateDay(); + void getdisplayDate( ); + +private: + int year; + int month; + int day; + +}; // end class Employee diff --git a/201816040319/Ex03_15/Ex03_15.cpp b/201816040319/Ex03_15/Ex03_15.cpp new file mode 100644 index 0000000..3944ba0 --- /dev/null +++ b/201816040319/Ex03_15/Ex03_15.cpp @@ -0,0 +1,35 @@ + +// Create Date objects. +#include +using namespace std; + +#include "Date.h" // include definition of class Date + +// function main begins program execution +int main() +{ + int Month; + int Day; + int Year; + cout <<"plese input your number"<>Month; + cout <<"Day"<>Day; + cout <<"Year"<>Year; + + Date date(Month,Day,Year); + + + cout <<"检验数据:"<