From f5bc8dc35f2933d807482b8aca98c53a64d60f9b Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Wed, 6 Nov 2019 17:37:25 +0800 Subject: [PATCH 01/24] Create Ex09_11.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_11/Ex09_11.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 201816040319/Ex09_11/Ex09_11.cpp diff --git a/201816040319/Ex09_11/Ex09_11.cpp b/201816040319/Ex09_11/Ex09_11.cpp new file mode 100644 index 00000000..c992e054 --- /dev/null +++ b/201816040319/Ex09_11/Ex09_11.cpp @@ -0,0 +1,31 @@ +#include +#include + +#include "Rectangle.h" + +using namespace std; + +int main() +{ + + Rectangle r; + double Length; + double Width; + + cout <<"please enter Length"<>Length; + cout <<"please enter width"<>Width; + + r.setRectangle(Length,Width); + + cout <<"Check the data"< Date: Wed, 6 Nov 2019 17:38:23 +0800 Subject: [PATCH 02/24] Create Rectangle.h This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_11/Rectangle.h | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 201816040319/Ex09_11/Rectangle.h diff --git a/201816040319/Ex09_11/Rectangle.h b/201816040319/Ex09_11/Rectangle.h new file mode 100644 index 00000000..58c1da6f --- /dev/null +++ b/201816040319/Ex09_11/Rectangle.h @@ -0,0 +1,11 @@ +class Rectangle +{ +public: + Rectangle(); + void setRectangle(double,double); + double perimenter(); + double area(); +private: + double length;//Define the length variable + double width; //Define the width variable +};//The end of class From e6d0b0d3cb7a56b20079dd6984a7697a914c670c Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Wed, 6 Nov 2019 17:39:23 +0800 Subject: [PATCH 03/24] Create Rectangle.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_11/Rectangle.cpp | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 201816040319/Ex09_11/Rectangle.cpp diff --git a/201816040319/Ex09_11/Rectangle.cpp b/201816040319/Ex09_11/Rectangle.cpp new file mode 100644 index 00000000..33b38297 --- /dev/null +++ b/201816040319/Ex09_11/Rectangle.cpp @@ -0,0 +1,33 @@ +#include +#include "Rectangle.h" +#include +using namespace std; + +Rectangle::Rectangle() + :length(0.0),width(0.0) + { + + } +void Rectangle::setRectangle(double Length,double Width) +{ + if((Length<20.0&&Length>0.0)&&(Width>0.0&&Width<20.0)) + { + length=Length; + width=Width; + } + /* else + thow invalide_argument( + "length,OR width was out of range"); + +*/}//end function rectangle + +double Rectangle::perimenter() +{ + return (2*length+2*width); +}//end function perimenter; + +double Rectangle::area() +{ + return length*width; +} +//end function area; From 1c1bdae820b4c95d463f821f9ba91ce2db187556 Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 16:24:41 +0800 Subject: [PATCH 04/24] Create Time.h This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_22/Time.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 201816040319/Ex09_22/Time.h diff --git a/201816040319/Ex09_22/Time.h b/201816040319/Ex09_22/Time.h new file mode 100644 index 00000000..96d3570f --- /dev/null +++ b/201816040319/Ex09_22/Time.h @@ -0,0 +1,31 @@ + +#include +class Time +{ +public: + explicit Time(int ,int ,int); + void timechange(); + void printTime(); + void setTime(int ,int ,int ); + void setHour(int ); + void setMinute(int ); + void setSecond(int ); + void timetick(); + void timein(int ); + int getHour() const; + int getMinute() const; + int getSecond() const; + + void printUniversal() const; + void printStandard() const; +private: + int hour; + int minute; + int second; + int alltime; + time_t tdata1; + time_t tdata2; + +}; + + From 9df965952d4fa14be438aeaaafcef7273f7ad462 Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 16:26:01 +0800 Subject: [PATCH 05/24] Create Time.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_22/Time.cpp | 116 ++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 201816040319/Ex09_22/Time.cpp diff --git a/201816040319/Ex09_22/Time.cpp b/201816040319/Ex09_22/Time.cpp new file mode 100644 index 00000000..dfff5270 --- /dev/null +++ b/201816040319/Ex09_22/Time.cpp @@ -0,0 +1,116 @@ +#include +#include +#include +#include"Time.h" +using namespace std; + +Time::Time(int hour,int minute,int second) +{ + setTime(hour,minute,second); +} +void Time::setTime(int h,int m,int s) +{ + setHour(h); + setMinute(m); + setSecond(s); +} +void Time::timechange() +{ + time(&date1); + localtime(&data2); +} +void Time::printTime() +{ + cout<<"The time is :"<=0&&h<24) + { + hour=h; + } + else + throw invalid_argument("minute must be in the range of 0-23"); + +} +void Time::setMinute(int m ) +{ + if(m>=0&&m<60) + { + minute=m; + } + else + throw invalid_argument("minute must be in the range of 0-59"); + +} +void Time::setSecond(int s ) +{ + if(s>=0&&s<60) + { + second=s; + } + else + throw invalid_argument("minute must be in the range of 0-59"); + +} +void Time::timetick() +{ + second++; + if(second==60) + { + minute++; + second=0; + } + if(minute==60) + { + hour++; + minute=0; + } + if(hour==24) + { + hour=0; + } +} +void Time::timein(int all)//自午夜以来的时间初始化 +{ + int h,m,s; + int a; + h=all/3600; + a=all%3600; + m=a/60; + a=a%60; + s=a; + setHour(h); + setMinute(m); + setSecond(s); +} + int Time::getHour() const +{ + return hour; +} + int Time::getMinute() const/ +{ + return minute; +} +int Time::getSecond() const//得到秒数 +{ + return second; +} +void Time::printUniversal() const +{ + cout< Date: Sun, 17 Nov 2019 16:27:53 +0800 Subject: [PATCH 06/24] Create Ex09_22.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_22/Ex09_22.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 201816040319/Ex09_22/Ex09_22.cpp diff --git a/201816040319/Ex09_22/Ex09_22.cpp b/201816040319/Ex09_22/Ex09_22.cpp new file mode 100644 index 00000000..03599fba --- /dev/null +++ b/201816040319/Ex09_22/Ex09_22.cpp @@ -0,0 +1,29 @@ +#include +#include"Time.h" +using namespace std; + +int main() +{ + Time t1; + t1.setTime(10,49,59); + t1.printStandard(); + cout< Date: Sun, 17 Nov 2019 16:30:05 +0800 Subject: [PATCH 07/24] Delete Ex09_22.cpp --- 201816040319/Ex09_22/Ex09_22.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 201816040319/Ex09_22/Ex09_22.cpp diff --git a/201816040319/Ex09_22/Ex09_22.cpp b/201816040319/Ex09_22/Ex09_22.cpp deleted file mode 100644 index 03599fba..00000000 --- a/201816040319/Ex09_22/Ex09_22.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include"Time.h" -using namespace std; - -int main() -{ - Time t1; - t1.setTime(10,49,59); - t1.printStandard(); - cout< Date: Sun, 17 Nov 2019 16:30:16 +0800 Subject: [PATCH 08/24] Delete Time.cpp --- 201816040319/Ex09_22/Time.cpp | 116 ---------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 201816040319/Ex09_22/Time.cpp diff --git a/201816040319/Ex09_22/Time.cpp b/201816040319/Ex09_22/Time.cpp deleted file mode 100644 index dfff5270..00000000 --- a/201816040319/Ex09_22/Time.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include -#include"Time.h" -using namespace std; - -Time::Time(int hour,int minute,int second) -{ - setTime(hour,minute,second); -} -void Time::setTime(int h,int m,int s) -{ - setHour(h); - setMinute(m); - setSecond(s); -} -void Time::timechange() -{ - time(&date1); - localtime(&data2); -} -void Time::printTime() -{ - cout<<"The time is :"<=0&&h<24) - { - hour=h; - } - else - throw invalid_argument("minute must be in the range of 0-23"); - -} -void Time::setMinute(int m ) -{ - if(m>=0&&m<60) - { - minute=m; - } - else - throw invalid_argument("minute must be in the range of 0-59"); - -} -void Time::setSecond(int s ) -{ - if(s>=0&&s<60) - { - second=s; - } - else - throw invalid_argument("minute must be in the range of 0-59"); - -} -void Time::timetick() -{ - second++; - if(second==60) - { - minute++; - second=0; - } - if(minute==60) - { - hour++; - minute=0; - } - if(hour==24) - { - hour=0; - } -} -void Time::timein(int all)//自午夜以来的时间初始化 -{ - int h,m,s; - int a; - h=all/3600; - a=all%3600; - m=a/60; - a=a%60; - s=a; - setHour(h); - setMinute(m); - setSecond(s); -} - int Time::getHour() const -{ - return hour; -} - int Time::getMinute() const/ -{ - return minute; -} -int Time::getSecond() const//得到秒数 -{ - return second; -} -void Time::printUniversal() const -{ - cout< Date: Sun, 17 Nov 2019 16:30:26 +0800 Subject: [PATCH 09/24] Delete Time.h --- 201816040319/Ex09_22/Time.h | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 201816040319/Ex09_22/Time.h diff --git a/201816040319/Ex09_22/Time.h b/201816040319/Ex09_22/Time.h deleted file mode 100644 index 96d3570f..00000000 --- a/201816040319/Ex09_22/Time.h +++ /dev/null @@ -1,31 +0,0 @@ - -#include -class Time -{ -public: - explicit Time(int ,int ,int); - void timechange(); - void printTime(); - void setTime(int ,int ,int ); - void setHour(int ); - void setMinute(int ); - void setSecond(int ); - void timetick(); - void timein(int ); - int getHour() const; - int getMinute() const; - int getSecond() const; - - void printUniversal() const; - void printStandard() const; -private: - int hour; - int minute; - int second; - int alltime; - time_t tdata1; - time_t tdata2; - -}; - - From 8bed50f6d8205a40df993f5f065045446318272e Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 16:40:09 +0800 Subject: [PATCH 10/24] Create Time.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_22/Time.cpp | 116 ++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 201816040319/Ex09_22/Time.cpp diff --git a/201816040319/Ex09_22/Time.cpp b/201816040319/Ex09_22/Time.cpp new file mode 100644 index 00000000..e5a5dcf7 --- /dev/null +++ b/201816040319/Ex09_22/Time.cpp @@ -0,0 +1,116 @@ +#include +#include +#include +#include"Time.h" +using namespace std; + +Time::Time(int hour,int minute,int second) +{ + setTime(hour,minute,second); +} +void Time::setTime(int h,int m,int s) +{ + setHour(h); + setMinute(m); + setSecond(s); +} +void Time::timechange() +{ + time(&data1); + localtime(&data2); +} +void Time::printTime() +{ + cout<<"The time is :"<=0&&h<24) + { + hour=h; + } + else + throw invalid_argument("minute must be in the range of 0-23"); + +} +void Time::setMinute(int m ) +{ + if(m>=0&&m<60) + { + minute=m; + } + else + throw invalid_argument("minute must be in the range of 0-59"); + +} +void Time::setSecond(int s ) +{ + if(s>=0&&s<60) + { + second=s; + } + else + throw invalid_argument("minute must be in the range of 0-59"); + +} +void Time::timetick() +{ + second++; + if(second==60) + { + minute++; + second=0; + } + if(minute==60) + { + hour++; + minute=0; + } + if(hour==24) + { + hour=0; + } +} +void Time::timein(int all) +{ + int h,m,s; + int a; + h=all/3600; + a=all%3600; + m=a/60; + a=a%60; + s=a; + setHour(h); + setMinute(m); + setSecond(s); +} + int Time::getHour() const +{ + return hour; +} + int Time::getMinute() const +{ + return minute; +} +int Time::getSecond() const +{ + return second; +} +void Time::printUniversal() const +{ + cout< Date: Sun, 17 Nov 2019 16:40:40 +0800 Subject: [PATCH 11/24] Create Time.h This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_22/Time.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 201816040319/Ex09_22/Time.h diff --git a/201816040319/Ex09_22/Time.h b/201816040319/Ex09_22/Time.h new file mode 100644 index 00000000..c8ba07d4 --- /dev/null +++ b/201816040319/Ex09_22/Time.h @@ -0,0 +1,31 @@ + +#include +class Time +{ +public: + explicit Time(int=0 ,int=0 ,int=0); + void timechange(); + void printTime(); + void setTime(int ,int ,int ); + void setHour(int ); + void setMinute(int ); + void setSecond(int ); + void timetick(); + void timein(int ); + int getHour() const; + int getMinute() const; + int getSecond() const; + + void printUniversal() const; + void printStandard() const; +private: + int hour; + int minute; + int second; + int alltime; + time_t data1; + time_t data2; + +}; + + From dda6c0e46a75d0f95f1689d906ae352415e8730a Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 16:41:27 +0800 Subject: [PATCH 12/24] Create Ex09_22.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_22/Ex09_22.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 201816040319/Ex09_22/Ex09_22.cpp diff --git a/201816040319/Ex09_22/Ex09_22.cpp b/201816040319/Ex09_22/Ex09_22.cpp new file mode 100644 index 00000000..03599fba --- /dev/null +++ b/201816040319/Ex09_22/Ex09_22.cpp @@ -0,0 +1,29 @@ +#include +#include"Time.h" +using namespace std; + +int main() +{ + Time t1; + t1.setTime(10,49,59); + t1.printStandard(); + cout< Date: Sun, 17 Nov 2019 17:27:59 +0800 Subject: [PATCH 13/24] Create Rectangle.h This is my assignment_04; student ID:201816040319 --- 201816040319/Rectangle.h | 106 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 201816040319/Rectangle.h diff --git a/201816040319/Rectangle.h b/201816040319/Rectangle.h new file mode 100644 index 00000000..4e47e24a --- /dev/null +++ b/201816040319/Rectangle.h @@ -0,0 +1,106 @@ +#include +#include"Rectangle.h" +#include +#include +#include +using namespace std; +Rectangle::Rectangle(int length,int width) +{ + setlength(length); + setwidth(width); +} +int Rectangle::perimeter() +{ + int perimeter; + perimeter = 2*lengthdata+2*widthdata; + return perimeter; +} +int Rectangle::area() +{ + int area; + area = lengthdata*widthdata; + return area; +} +void Rectangle::setlength(int length) +{ + lengthdata = length; +} +void Rectangle::setwidth(int width) +{ + widthdata = width; +} +void Rectangle::draw() +{ + + int l=(25-lengthdata)/2;//求除了长方形的长剩下的长 + int w=(25-widthdata)/2;//求除了长方形的宽剩下的宽 + int i,k; + //外部构造循环 + for( i = 0;i<25;i++) + { + if(i==0||i==24) + { for(int j =0; j <25;j++) + { + cout< Date: Sun, 17 Nov 2019 17:28:21 +0800 Subject: [PATCH 14/24] Delete Rectangle.h --- 201816040319/Rectangle.h | 106 --------------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 201816040319/Rectangle.h diff --git a/201816040319/Rectangle.h b/201816040319/Rectangle.h deleted file mode 100644 index 4e47e24a..00000000 --- a/201816040319/Rectangle.h +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include"Rectangle.h" -#include -#include -#include -using namespace std; -Rectangle::Rectangle(int length,int width) -{ - setlength(length); - setwidth(width); -} -int Rectangle::perimeter() -{ - int perimeter; - perimeter = 2*lengthdata+2*widthdata; - return perimeter; -} -int Rectangle::area() -{ - int area; - area = lengthdata*widthdata; - return area; -} -void Rectangle::setlength(int length) -{ - lengthdata = length; -} -void Rectangle::setwidth(int width) -{ - widthdata = width; -} -void Rectangle::draw() -{ - - int l=(25-lengthdata)/2;//求除了长方形的长剩下的长 - int w=(25-widthdata)/2;//求除了长方形的宽剩下的宽 - int i,k; - //外部构造循环 - for( i = 0;i<25;i++) - { - if(i==0||i==24) - { for(int j =0; j <25;j++) - { - cout< Date: Sun, 17 Nov 2019 17:29:07 +0800 Subject: [PATCH 15/24] Create Rectangle.h This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_12/Rectangle.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 201816040319/Ex09_12/Rectangle.h diff --git a/201816040319/Ex09_12/Rectangle.h b/201816040319/Ex09_12/Rectangle.h new file mode 100644 index 00000000..b5400fd8 --- /dev/null +++ b/201816040319/Ex09_12/Rectangle.h @@ -0,0 +1,29 @@ +#include +#include + + +class Rectangle +{ + +public: + Rectangle(double ,double ); + double perimeter(); + double area(); + void setlength(double ); + void setwidth(double ); + void draw(); + void setCharacter(char out); + void setPerimeterCharacter(char in); + double getlength(); + double getwidth(); +private: + double Length; + double Width; + char outnumber; + char innumber; + +}; + + + + From a69e147552fb0194a47ea270020fac5fd3c15acd Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 17:29:57 +0800 Subject: [PATCH 16/24] Create Rectangle.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_12/Rectangle.cpp | 106 +++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 201816040319/Ex09_12/Rectangle.cpp diff --git a/201816040319/Ex09_12/Rectangle.cpp b/201816040319/Ex09_12/Rectangle.cpp new file mode 100644 index 00000000..0ae4a804 --- /dev/null +++ b/201816040319/Ex09_12/Rectangle.cpp @@ -0,0 +1,106 @@ + +#include +#include"Rectangle.h" +#include +#include +#include +using namespace std; +Rectangle::Rectangle(double length,double width) +{ + setlength(length); + setwidth(width); +} +double Rectangle::perimeter() +{ + int perimeter; + perimeter = 2*Length+2*Width; + return perimeter; +} +double Rectangle::area() +{ + int area; + area = Length*Width; + return area; +} +void Rectangle::setlength(double length) +{ + Length = length; +} +void Rectangle::setwidth(double width) +{ + Width = width; +} +void Rectangle::draw() +{ + + double l=(25-Length)/2; + double w=(25-Width)/2; + int i,k; + for( i = 0;i<25;i++) + { + if(i==0||i==24) + { for(int j =0; j <25;j++) + { + cout< Date: Sun, 17 Nov 2019 17:30:39 +0800 Subject: [PATCH 17/24] Create Ex09_12.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_12/Ex09_12.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 201816040319/Ex09_12/Ex09_12.cpp diff --git a/201816040319/Ex09_12/Ex09_12.cpp b/201816040319/Ex09_12/Ex09_12.cpp new file mode 100644 index 00000000..7fc74f0e --- /dev/null +++ b/201816040319/Ex09_12/Ex09_12.cpp @@ -0,0 +1,21 @@ +#include +#include"Rectangle.h" +using namespace std; + +int main() +{ + Rectangle r(5.0,2.0); + int perimeter,area,width,length; + width = r.getwidth(); + length = r.getlength(); + perimeter=r.perimeter(); + area = r.area(); + cout<<"this width is :"< Date: Sun, 17 Nov 2019 17:39:26 +0800 Subject: [PATCH 18/24] Create Card.h This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_23/Card.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 201816040319/Ex09_23/Card.h diff --git a/201816040319/Ex09_23/Card.h b/201816040319/Ex09_23/Card.h new file mode 100644 index 00000000..491b9daf --- /dev/null +++ b/201816040319/Ex09_23/Card.h @@ -0,0 +1,29 @@ +#include +#include"card.h" +#include + +Card::Card(int Face,int Suit) +{ + face = Face; + suit = Suit; +} +string Card::toString() +{ + return facedata[face]+" of "+suitdata[suit]; +} +int Card::getface() +{ + return face; +} +int Card::getsuit() +{ + return suit; +} + +const string Card::facedata[facenumber]= +{"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; + +const string Card::suitdata[suitnumber]= +{"heart","diamond","club","spade"}; + + From 29485d306d69150cc1c45ce625f7271a4928b0e2 Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 17:41:30 +0800 Subject: [PATCH 19/24] Delete Card.h --- 201816040319/Ex09_23/Card.h | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 201816040319/Ex09_23/Card.h diff --git a/201816040319/Ex09_23/Card.h b/201816040319/Ex09_23/Card.h deleted file mode 100644 index 491b9daf..00000000 --- a/201816040319/Ex09_23/Card.h +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include"card.h" -#include - -Card::Card(int Face,int Suit) -{ - face = Face; - suit = Suit; -} -string Card::toString() -{ - return facedata[face]+" of "+suitdata[suit]; -} -int Card::getface() -{ - return face; -} -int Card::getsuit() -{ - return suit; -} - -const string Card::facedata[facenumber]= -{"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; - -const string Card::suitdata[suitnumber]= -{"heart","diamond","club","spade"}; - - From 13e10fd26756dc5596186f4bfea55dd44bc5c0a4 Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 17:43:36 +0800 Subject: [PATCH 20/24] Create Card.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_23/Card.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 201816040319/Ex09_23/Card.cpp diff --git a/201816040319/Ex09_23/Card.cpp b/201816040319/Ex09_23/Card.cpp new file mode 100644 index 00000000..491b9daf --- /dev/null +++ b/201816040319/Ex09_23/Card.cpp @@ -0,0 +1,29 @@ +#include +#include"card.h" +#include + +Card::Card(int Face,int Suit) +{ + face = Face; + suit = Suit; +} +string Card::toString() +{ + return facedata[face]+" of "+suitdata[suit]; +} +int Card::getface() +{ + return face; +} +int Card::getsuit() +{ + return suit; +} + +const string Card::facedata[facenumber]= +{"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; + +const string Card::suitdata[suitnumber]= +{"heart","diamond","club","spade"}; + + From e3bc501e6abbf13d1027ba15595cee9694300ff5 Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 17:46:22 +0800 Subject: [PATCH 21/24] Create Card.h This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_23/Card.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 201816040319/Ex09_23/Card.h diff --git a/201816040319/Ex09_23/Card.h b/201816040319/Ex09_23/Card.h new file mode 100644 index 00000000..a83bc238 --- /dev/null +++ b/201816040319/Ex09_23/Card.h @@ -0,0 +1,24 @@ +#include +#include +using namespace std; + +class Card +{ +public: + static const int facenumber = 13; + static const int suitnumber = 4; + Card(int ,int ); + int getface(); + int getsuit(); + string toString(); +private: + int face; + int suit; + static const string facedata[facenumber]; + static const string suitdata[suitnumber]; + + +}; + + + From 6553e3edfdccb5062d636d5962745042d02b3bb0 Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 17:47:59 +0800 Subject: [PATCH 22/24] Create DeckOfCards.h This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_23/DeckOfCards.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 201816040319/Ex09_23/DeckOfCards.h diff --git a/201816040319/Ex09_23/DeckOfCards.h b/201816040319/Ex09_23/DeckOfCards.h new file mode 100644 index 00000000..8a8f42e8 --- /dev/null +++ b/201816040319/Ex09_23/DeckOfCards.h @@ -0,0 +1,21 @@ +#include +#include +#include"Card.h" + +using namespace std; + +class DeckOfCards +{ +public: + DeckOfCards(); + void shuffle(); + Card dealcard(int ); + void beforecard(int ); + bool morecard(); + void judge(int ); +private: + vector deck; + int currentCard; +}; + + From b99b2adde5547d9937a54d889868052a705a1109 Mon Sep 17 00:00:00 2001 From: zhouyuxaing <56668463+zhouyuxaing@users.noreply.github.com> Date: Sun, 17 Nov 2019 17:53:25 +0800 Subject: [PATCH 23/24] Create deckofcards.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_23/deckofcards.cpp | 211 +++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 201816040319/Ex09_23/deckofcards.cpp diff --git a/201816040319/Ex09_23/deckofcards.cpp b/201816040319/Ex09_23/deckofcards.cpp new file mode 100644 index 00000000..aae6a746 --- /dev/null +++ b/201816040319/Ex09_23/deckofcards.cpp @@ -0,0 +1,211 @@ +#include +#include +#include"DeckOfCards.h" +#include"card.h" +#include +#include +#include + +DeckOfCards::DeckOfCards() +{ + + for (int j =0;j<52;j++) + { + Card card(j%13,j/13); + deck.push_back(card); + } + +} + +void DeckOfCards::shuffle() +{ + srand(time(0)); + int swap1[52]; + for (int j=0;j<52;j++) + { + swap1[j] = int (rand())%52; + } + + for (int i=0;i<52;i++) + { + Card change(0,0); + change = deck[i]; + deck[i] = deck[swap1[i]]; + deck[swap1[i]] = change + } +} +//返回下一张牌 +Card DeckOfCards::dealcard(int currentCard) +{ + cout<52||num<0) + { + cout<<"Enter a correct number!"; + } + else + { + for (int i = 0;i Date: Sun, 17 Nov 2019 17:59:54 +0800 Subject: [PATCH 24/24] Create Ex09_23.cpp This is my assignment_04; student ID:201816040319 --- 201816040319/Ex09_23/Ex09_23.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 201816040319/Ex09_23/Ex09_23.cpp diff --git a/201816040319/Ex09_23/Ex09_23.cpp b/201816040319/Ex09_23/Ex09_23.cpp new file mode 100644 index 00000000..09b6e288 --- /dev/null +++ b/201816040319/Ex09_23/Ex09_23.cpp @@ -0,0 +1,20 @@ +#include +#include"DeckOfCards.h" +#include"card.h" + +using namespace std; + +int main() +{ + DeckOfCards card1; + card1.shuffle(); + card1.beforecard(10); + cout<