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

Assignment -03 #127

Open
wants to merge 12 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
37 changes: 37 additions & 0 deletions 201816040319/Ex03_13/Ex03_13.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// github 3.13
// Invoice class definition.

#include <iostream>
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 <<"零件号:"<<endl;
cin >>Number;
cout <<"零件描述:"<<endl;
cin >>Style;
cout <<"销售总量:"<<endl;
cin >>Sell;
cout <<"单价:"<<endl;
cin >>Price;

Invoice invoice(Number,Style,Sell,Price);

cout <<"验证数据:"<<invoice.getInvoiceNumber()<<" "<<invoice.getInvoiceStyle()<<" "<<invoice.getInvoiceSell()<<" "<<invoice.getInvoicePrice()<<endl;

cout <<"计算数据:"<<invoice.getInvoiceAmmount();

return 0;


} // end main


65 changes: 65 additions & 0 deletions 201816040319/Ex03_13/Invoice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Invoice.cpp
// class member-function definitions.
#include <iostream>
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;
}
29 changes: 29 additions & 0 deletions 201816040319/Ex03_13/Invoice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// github 3.13
// Invoice class definition.

#include <string> // 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
49 changes: 49 additions & 0 deletions 201816040319/Ex03_15/Date.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

// Date class member-function definitions.
#include <iostream>
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:"<<month<<"/"<<day<<"/"<<year<<endl;
}
26 changes: 26 additions & 0 deletions 201816040319/Ex03_15/Date.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// gitub——3.15
// Date class definition.

#include <string> // 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
35 changes: 35 additions & 0 deletions 201816040319/Ex03_15/Ex03_15.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

// Create Date objects.
#include <iostream>
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"<<endl;
cout <<"Month(1~12)"<<endl;
cin >>Month;
cout <<"Day"<<endl;
cin >>Day;
cout <<"Year"<<endl;
cin >>Year;

Date date(Month,Day,Year);


cout <<"检验数据:"<<endl;
cout<<"Month:"<<date.getDateMonth()<<" "<<"Day:"<<date.getDateDay()<<" "<<"Year:"<<date.getDateYear()<<endl;


cout <<"输出数据:";
date.getdisplayDate();
return 0;

} // end main