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

Create Ex03_13 Ex03_15 #128

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
18 changes: 18 additions & 0 deletions 201816040103/Ex03_13/Ex03_13.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
using namespace std;

#include "Invoice.cpp"
int main()
{
Invoice Invoice1("A01","Well",10,15);
Invoice Invoice2("A02","Well",-1,15);
Invoice Invoice3("A03","Well",10,-1);
cout<<"The Invoice1 is "<<Invoice1.getPno()<<","<<Invoice1.getPnoDescribe()<<","<<Invoice1.getA()<<","<<Invoice1.getB()<<endl;

cout<<"The Invoice2 is "<<Invoice2.getPno()<<","<<Invoice2.getPnoDescribe()<<","<<Invoice2.getA()<<","<<Invoice2.getB()<<endl;
cout<<"The Invoice3 is "<<Invoice3.getPno()<<","<<Invoice3.getPnoDescribe()<<","<<Invoice3.getA()<<","<<Invoice3.getB()<<endl;

cout<<"The InvoiceAmount of Invoice1 is "<<Invoice1.getInvoiceAmount()<<endl;
cout<<"The InvoiceAmount of Invoice2 is "<<Invoice2.getInvoiceAmount()<<endl;
cout<<"The InvoiceAmount of Invoice3 is "<<Invoice3.getInvoiceAmount()<<endl;
}
63 changes: 63 additions & 0 deletions 201816040103/Ex03_13/Invoice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <string>
#include"Invoice.h"
using namespace std;

Invoice::Invoice(string pnol,string pnodescribel,int al,int bl)
{
setPno(pnol);
setPnoDescribe(pnodescribel);
setA(al);
setB(bl);
}

void Invoice::setPno(string pnol)
{
pno = pnol;
}

string Invoice::getPno()
{
return pno;
}

void Invoice::setPnoDescribe(string pnodescribel)
{
pnodescribe = pnodescribel;
}

string Invoice::getPnoDescribe()
{
return pnodescribe;
}

void Invoice::setA(int al)
{
if(al > 0)
a = al;
else
a = 0;
}

int Invoice::getA()
{
return a;
}

void Invoice::setB(int bl)
{
if(bl > 0)
b = bl;
else
b = 0;
}

int Invoice::getB()
{
return b;
}

int Invoice::getInvoiceAmount()
{
return getA()*getB();
}

22 changes: 22 additions & 0 deletions 201816040103/Ex03_13/Invoice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <string>
using namespace std;

class Invoice
{
public:
Invoice(string,string,int,int);
void setPno(string);
string getPno();
void setPnoDescribe(string);
string getPnoDescribe();
void setA(int);
int getA();
void setB(int);
int getB();
int getInvoiceAmount();
private:
string pno;
string pnodescribe;
int a;
int b;
};
50 changes: 50 additions & 0 deletions 201816040103/Ex03_15/Date.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <iostream>

#include "Date.h"

using namespace std;

Date::Date(int monthl,int dayl,int yearl)
{
setMonth(monthl);
setDay(dayl);
setYear(yearl);
}

void Date::setMonth(int monthl)
{
if(monthl > 0 && monthl < 13 )
month = monthl;
else
month = 1;
}

int Date::getMonth()
{
return month;
}

void Date::setDay(int dayl)
{
day = dayl;
}

int Date::getDay()
{
return day;
}

void Date::setYear(int yearl)
{
year = yearl;
}

int Date::getYear()
{
return year;
}

int Date::getdisplayDate()
{
cout<<"The Date is "<<getMonth()<<"/"<<getDay()<<"/"<<getYear()<<endl;
}
18 changes: 18 additions & 0 deletions 201816040103/Ex03_15/Date.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using namespace std;

class Date
{
public:
Date(int ,int ,int );
void setMonth(int);
int getMonth();
void setDay(int);
int getDay();
void setYear(int);
int getYear();
int getdisplayDate();
private:
int month;
int day;
int year;
};
14 changes: 14 additions & 0 deletions 201816040103/Ex03_15/Ex03_15.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <iostream>

#include "Date.h"

using namespace std;

int main()
{
Date Date1(11,4,2019);
Date Date2(15,4,2019);

Date1.getdisplayDate();
Date2.getdisplayDate();
}
2 changes: 2 additions & 0 deletions 201816040107/Ex03_13/Invoice.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#include <iostream>
#include<string>
#include "Invoice.h"
Expand Down Expand Up @@ -50,3 +51,4 @@ int Invoice::getInvoiceAmount(int n3,int n4)//getInvoiceAmount函数的定义;
return a;
}
}

1 change: 1 addition & 0 deletions 201816040107/Ex03_15/Date.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using namespace std;
class Date
{
public:
Date(int, int,int);//申明构造函数;
Date(int, int,int);//声明构造函数;
void setyear(int);
int getyear();
Expand Down