From 948f996bd217f83bfe2474826a92d8c9fe5cf995 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:38:13 +0800 Subject: [PATCH 01/26] Create Rectangle.h This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_11/Rectangle.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 201816040112/Ex09_11/Rectangle.h diff --git a/201816040112/Ex09_11/Rectangle.h b/201816040112/Ex09_11/Rectangle.h new file mode 100644 index 00000000..db2c1ffe --- /dev/null +++ b/201816040112/Ex09_11/Rectangle.h @@ -0,0 +1,21 @@ +#ifndef RECTANGLE_H_INCLUDED +#define RECTANGLE_H_INCLUDED + +class Rectangle{ + +public: + explicit Rectangle(double=1.0,double=1.0); + void setlength(double); + double getlength(); + void setwidth(double); + double getwidth(); + double perimeter(); + double area(); +private: + double width; + double length; + +}; + + +#endif // RECTANGLE_H_INCLUDED From 513c8162a9723fe93114ad2b5ee3b51d65064226 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:38:54 +0800 Subject: [PATCH 02/26] Create Rectangle.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_11/Rectangle.cpp | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 201816040112/Ex09_11/Rectangle.cpp diff --git a/201816040112/Ex09_11/Rectangle.cpp b/201816040112/Ex09_11/Rectangle.cpp new file mode 100644 index 00000000..3654ce28 --- /dev/null +++ b/201816040112/Ex09_11/Rectangle.cpp @@ -0,0 +1,40 @@ +#include "Rectangle.h" +#include + +Rectangle::Rectangle(double x,double y) +{ + setlength(x); + setwidth(y); +} +void Rectangle::setlength(double le) +{ + if(le>0&&le<20) + length=le; + else + length=0; +} +double Rectangle::getlength() +{ + return length; +} +void Rectangle::setwidth(double wi) +{ + if(wi>0&&wi<20) + width=wi; + else + width=0; +} +double Rectangle::getwidth() +{ + return width; +} +double Rectangle::perimeter() +{ + + return 2*(getlength()+getwidth()); +} +double Rectangle::area() +{ + + return getlength()*getwidth(); +} From 56569d152e9c39d2349caa92628ef68fd9bb6fcf Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:39:40 +0800 Subject: [PATCH 03/26] Create Ex09_11.cpp This is my assigmet_04 Student ID:201816040112 --- 201816040112/Ex09_11/Ex09_11.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 201816040112/Ex09_11/Ex09_11.cpp diff --git a/201816040112/Ex09_11/Ex09_11.cpp b/201816040112/Ex09_11/Ex09_11.cpp new file mode 100644 index 00000000..e1f3b920 --- /dev/null +++ b/201816040112/Ex09_11/Ex09_11.cpp @@ -0,0 +1,10 @@ +#include +#include "Rectangle.h" +using namespace std; + +int main() +{ + Rectangle myRectangle(10,15); + cout<<"长方形的周长为:"< Date: Sun, 10 Nov 2019 15:40:42 +0800 Subject: [PATCH 04/26] Create Rectangle.h This is my assigmet_04 Student ID:201816040112 --- 201816040112/Ex09_12/Rectangle.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 201816040112/Ex09_12/Rectangle.h diff --git a/201816040112/Ex09_12/Rectangle.h b/201816040112/Ex09_12/Rectangle.h new file mode 100644 index 00000000..99d9ee31 --- /dev/null +++ b/201816040112/Ex09_12/Rectangle.h @@ -0,0 +1,22 @@ +#ifndef RECTANGLE_H_INCLUDED +#define RECTANGLE_H_INCLUDED +#include "Point.h" +class Rectangle +{ +public: + explicit Rectangle(Point &,Point &,Point &); + double Relength(); + double Rewidth(); + double perimeter(); + double arear(); + bool square(); +private: + Point point1; + Point point2; + Point point3; + + +}; + + +#endif // RECTANGLE_H_INCLUDED From 8ebd55d220d8e4b433c1be0f67096abeb4421d07 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:41:05 +0800 Subject: [PATCH 05/26] Create Rectangle.cpp This is my assigmet_04 Student ID:201816040112 --- 201816040112/Ex09_12/Rectangle.cpp | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 201816040112/Ex09_12/Rectangle.cpp diff --git a/201816040112/Ex09_12/Rectangle.cpp b/201816040112/Ex09_12/Rectangle.cpp new file mode 100644 index 00000000..d95c1210 --- /dev/null +++ b/201816040112/Ex09_12/Rectangle.cpp @@ -0,0 +1,38 @@ +#include "Rectangle.h" +#include "Point.h" +#include +Rectangle::Rectangle(Point &x,Point &y,Point &z) +{ + point1=x; + point2=y; + point3=z; + + +} +double Rectangle::Relength() +{ + + + return fabs(point1.getxPoint()-point2.getxPoint()); + + +} +double Rectangle::Rewidth() +{ + return fabs(point3.getyPoint()-point1.getyPoint()); +} +double Rectangle::arear() +{ + return Relength()*Rewidth(); +} +double Rectangle::perimeter() +{ + return 2*(Relength()+Rewidth()); +} +bool Rectangle::square() +{ + if(Relength()==Rewidth()) + return true; + else + return false; +} From e7e3d6577c2e9e9407ed613cbcd4ddd13cfe30e9 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:41:27 +0800 Subject: [PATCH 06/26] Create Point.h This is my assigmet_04 Student ID:201816040112 --- 201816040112/Ex09_12/Point.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 201816040112/Ex09_12/Point.h diff --git a/201816040112/Ex09_12/Point.h b/201816040112/Ex09_12/Point.h new file mode 100644 index 00000000..b868cc74 --- /dev/null +++ b/201816040112/Ex09_12/Point.h @@ -0,0 +1,16 @@ +#ifndef POINT_H_INCLUDED +#define POINT_H_INCLUDED +class Point +{ +public: + explicit Point(double=0.0,double=0.0); + void setxPoint (const double); + double getxPoint (); + void setyPoint(const double); + double getyPoint(); +private: + double x,y; +}; + + +#endif // POINT_H_INCLUDED From 3aa716b30558e605ca5ef8093012e407da2cb9bc Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:42:17 +0800 Subject: [PATCH 07/26] Create Point.cpp This is my assigmet_04 Student ID:201816040112 --- 201816040112/Ex09_12/Point.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 201816040112/Ex09_12/Point.cpp diff --git a/201816040112/Ex09_12/Point.cpp b/201816040112/Ex09_12/Point.cpp new file mode 100644 index 00000000..4a8b9dd3 --- /dev/null +++ b/201816040112/Ex09_12/Point.cpp @@ -0,0 +1,29 @@ +#include "Point.h" + +Point::Point(double tx,double ty) +{ + setxPoint(tx); + setyPoint(ty); +} +void Point::setxPoint(const double tx) +{ + if(tx>=0&&tx<=20) + x=tx; + else + x=0; +} +void Point::setyPoint(const double ty) +{ + if(ty>=0&&ty<=20) + y=ty; + else + y=0; +} +double Point::getxPoint() +{ + return x; +} +double Point::getyPoint() +{ + return y; +} From 0e3f78e6f1d0e154e52b5d5b6dfed0834d4b7ce9 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:43:11 +0800 Subject: [PATCH 08/26] Create Ex09_12.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_12/Ex09_12.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 201816040112/Ex09_12/Ex09_12.cpp diff --git a/201816040112/Ex09_12/Ex09_12.cpp b/201816040112/Ex09_12/Ex09_12.cpp new file mode 100644 index 00000000..ad6f2c09 --- /dev/null +++ b/201816040112/Ex09_12/Ex09_12.cpp @@ -0,0 +1,18 @@ +#include +#include "Point.h" +#include "Rectangle.h" +using namespace std; + +int main() +{ + Point point1(2,3); + Point point2(7,3); + Point point3(2,0); + Rectangle myRectangle(point1,point2,point3); + cout<<"这个四方形的长为:"< Date: Sun, 10 Nov 2019 15:44:04 +0800 Subject: [PATCH 09/26] Create Time.h This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_22/Time.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 201816040112/Ex09_22/Time.h diff --git a/201816040112/Ex09_22/Time.h b/201816040112/Ex09_22/Time.h new file mode 100644 index 00000000..3e7ab398 --- /dev/null +++ b/201816040112/Ex09_22/Time.h @@ -0,0 +1,17 @@ +#ifndef TIME_H_INCLUDED +#define TIME_H_INCLUDED +class Time +{ +public: + explicit Time(int=0,int=0,int=0); + int gethour(); + int getminute(); + int getsecond(); + void display(); +private: + int sec=0; + +}; + + +#endif // TIME_H_INCLUDED From a0ef071d605c3cbfff8f370025d432e4cc19bb36 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:44:23 +0800 Subject: [PATCH 10/26] Create Time.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_22/Time.cpp | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 201816040112/Ex09_22/Time.cpp diff --git a/201816040112/Ex09_22/Time.cpp b/201816040112/Ex09_22/Time.cpp new file mode 100644 index 00000000..e6115590 --- /dev/null +++ b/201816040112/Ex09_22/Time.cpp @@ -0,0 +1,48 @@ +#include "Time.h" +#include +using namespace std; +Time::Time(int th,int tm,int ts) +{ + sec=3600*th+60*tm+ts; //get the sum of seconds; +} +int Time::gethour() +{ + int a=0; + while(sec>3600) + { + sec=sec-3600; + a++; + } + + return a; +} +int Time::getminute() +{ + int a=0; + while(sec>60) + { + sec=sec-60; + a++; + } + + return a; +} +int Time::getsecond() +{ + int a=0; + while(sec>0) + { + sec--; + a++; + } + + return a; +} +void Time::display() +{ + int a,b,c; + a=gethour(); + b=getminute(); + c=getsecond(); + cout< Date: Sun, 10 Nov 2019 15:45:23 +0800 Subject: [PATCH 11/26] Create Ex09_22.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_22/Ex09_22.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 201816040112/Ex09_22/Ex09_22.cpp diff --git a/201816040112/Ex09_22/Ex09_22.cpp b/201816040112/Ex09_22/Ex09_22.cpp new file mode 100644 index 00000000..eafd3071 --- /dev/null +++ b/201816040112/Ex09_22/Ex09_22.cpp @@ -0,0 +1,10 @@ +#include +#include "Time.h" +using namespace std; + +int main() +{ + Time mytime(10,30,49); + mytime.display(); + return 0; +} From f34bb449aefca6d99d5f10e44f9c9cbe17b62a4e Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:46:47 +0800 Subject: [PATCH 12/26] Create Card.h This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23.cpp/Card.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 201816040112/Ex09_23.cpp/Card.h diff --git a/201816040112/Ex09_23.cpp/Card.h b/201816040112/Ex09_23.cpp/Card.h new file mode 100644 index 00000000..7775d3ae --- /dev/null +++ b/201816040112/Ex09_23.cpp/Card.h @@ -0,0 +1,24 @@ +#ifndef CARD_H_INCLUDED +#define CARD_H_INCLUDED + +#include +using namespace std; +class Card +{ + friend class Doc; +public: + explicit Card(int,int); + string toString(); +private: + int face,suit; + + string number[13]={"1","2","3","4","5","6","7","8","9","10","11","12","13"}; + string color[4]={"Spade","Heart","Diamond","Club"}; + + + + +}; + + +#endif // CARD_H_INCLUDED From defa64ab777b0c33890d14d4f92f3f02decaf4cc Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:47:26 +0800 Subject: [PATCH 13/26] Create Card.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23.cpp/Card.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 201816040112/Ex09_23.cpp/Card.cpp diff --git a/201816040112/Ex09_23.cpp/Card.cpp b/201816040112/Ex09_23.cpp/Card.cpp new file mode 100644 index 00000000..a87f5588 --- /dev/null +++ b/201816040112/Ex09_23.cpp/Card.cpp @@ -0,0 +1,14 @@ +#include "Card.h" + + +Card::Card(int a,int b) +{ + face=a; + suit=b; +} +string Card::toString() +{ + string res=""; + res=color[suit]+" "+number[face]; + return res; +} From f2fc77e42c6bd116124fc3fa632f6c9af9b32cce Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:47:58 +0800 Subject: [PATCH 14/26] Create DeckofCards.h This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23.cpp/DeckofCards.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 201816040112/Ex09_23.cpp/DeckofCards.h diff --git a/201816040112/Ex09_23.cpp/DeckofCards.h b/201816040112/Ex09_23.cpp/DeckofCards.h new file mode 100644 index 00000000..4098df52 --- /dev/null +++ b/201816040112/Ex09_23.cpp/DeckofCards.h @@ -0,0 +1,22 @@ +#ifndef DECKOFCARDS_H_INCLUDED +#define DECKOFCARDS_H_INCLUDED +#include "Card.h" +#include +class Doc +{ +public: + explicit Doc(); + void shuffle(); + vector deck; + bool moreCards(); + void dealCards(); + +private: + int currentCard; + int k=0; + + +}; + + +#endif // DECKOFCARDS_H_INCLUDED From 85b9b3ddc03d8cb48f32c9ffa8d5509fb1248889 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:48:26 +0800 Subject: [PATCH 15/26] Create DeckofCards.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23.cpp/DeckofCards.cpp | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 201816040112/Ex09_23.cpp/DeckofCards.cpp diff --git a/201816040112/Ex09_23.cpp/DeckofCards.cpp b/201816040112/Ex09_23.cpp/DeckofCards.cpp new file mode 100644 index 00000000..17d629e2 --- /dev/null +++ b/201816040112/Ex09_23.cpp/DeckofCards.cpp @@ -0,0 +1,49 @@ +#include "Card.h" +#include "DeckOfCards.h" +#include +#include +#include +#include +Doc::Doc() +{ + int i,j; + for(i=0;i<4;i++) + { + for(j=0;j<13;j++){ + Card temp(j,i); + deck.push_back(temp); + + } + + + } +} +void Doc::shuffle() +{ + vector temp; + int j=0,i; + for(i=0;i<52;i++){ + temp.push_back(i); + } + std::random_shuffle(temp.begin(), temp.end()); + for(i=0;i<52;i++){ + j=i+1; + swap(deck[temp[i]],deck[temp[j]]); + i++; + } + + +} +void Doc::dealCards() +{ + + cout<=52) + return false; + else + return true; +} From 0c6a202e74fedaec6468e8d984774c2ec28f7d73 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 15:49:11 +0800 Subject: [PATCH 16/26] Create Ex09_23.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23.cpp/Ex09_23.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 201816040112/Ex09_23.cpp/Ex09_23.cpp diff --git a/201816040112/Ex09_23.cpp/Ex09_23.cpp b/201816040112/Ex09_23.cpp/Ex09_23.cpp new file mode 100644 index 00000000..b3a1348e --- /dev/null +++ b/201816040112/Ex09_23.cpp/Ex09_23.cpp @@ -0,0 +1,15 @@ +#include +#include "Card.h" +#include "DeckOfCards.h" +#include +using namespace std; + +int main() +{ + Doc mycard; + mycard.shuffle(); + while(mycard.moreCards()==true){ + mycard.dealCards(); + } + return 0; +} From 5760ff4dd485c3b55d74a933865b45ac0d3ce9b3 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:06:03 +0800 Subject: [PATCH 17/26] Create Card.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23/Card.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 201816040112/Ex09_23/Card.cpp diff --git a/201816040112/Ex09_23/Card.cpp b/201816040112/Ex09_23/Card.cpp new file mode 100644 index 00000000..a87f5588 --- /dev/null +++ b/201816040112/Ex09_23/Card.cpp @@ -0,0 +1,14 @@ +#include "Card.h" + + +Card::Card(int a,int b) +{ + face=a; + suit=b; +} +string Card::toString() +{ + string res=""; + res=color[suit]+" "+number[face]; + return res; +} From 3b78fc43ae8c6f33045ceeebf01edb397383bed5 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:08:52 +0800 Subject: [PATCH 18/26] Create Card.h This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23/Card.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 201816040112/Ex09_23/Card.h diff --git a/201816040112/Ex09_23/Card.h b/201816040112/Ex09_23/Card.h new file mode 100644 index 00000000..7775d3ae --- /dev/null +++ b/201816040112/Ex09_23/Card.h @@ -0,0 +1,24 @@ +#ifndef CARD_H_INCLUDED +#define CARD_H_INCLUDED + +#include +using namespace std; +class Card +{ + friend class Doc; +public: + explicit Card(int,int); + string toString(); +private: + int face,suit; + + string number[13]={"1","2","3","4","5","6","7","8","9","10","11","12","13"}; + string color[4]={"Spade","Heart","Diamond","Club"}; + + + + +}; + + +#endif // CARD_H_INCLUDED From 7631bac8977148381d71bc58772ccfa266878027 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:09:24 +0800 Subject: [PATCH 19/26] Create DeckofCards.h This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23/DeckofCards.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 201816040112/Ex09_23/DeckofCards.h diff --git a/201816040112/Ex09_23/DeckofCards.h b/201816040112/Ex09_23/DeckofCards.h new file mode 100644 index 00000000..4098df52 --- /dev/null +++ b/201816040112/Ex09_23/DeckofCards.h @@ -0,0 +1,22 @@ +#ifndef DECKOFCARDS_H_INCLUDED +#define DECKOFCARDS_H_INCLUDED +#include "Card.h" +#include +class Doc +{ +public: + explicit Doc(); + void shuffle(); + vector deck; + bool moreCards(); + void dealCards(); + +private: + int currentCard; + int k=0; + + +}; + + +#endif // DECKOFCARDS_H_INCLUDED From e41dc0992d9fb26f0c0a5f9b11d08d9f3917efb5 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:09:55 +0800 Subject: [PATCH 20/26] Create DeckofCards.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23/DeckofCards.cpp | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 201816040112/Ex09_23/DeckofCards.cpp diff --git a/201816040112/Ex09_23/DeckofCards.cpp b/201816040112/Ex09_23/DeckofCards.cpp new file mode 100644 index 00000000..17d629e2 --- /dev/null +++ b/201816040112/Ex09_23/DeckofCards.cpp @@ -0,0 +1,49 @@ +#include "Card.h" +#include "DeckOfCards.h" +#include +#include +#include +#include +Doc::Doc() +{ + int i,j; + for(i=0;i<4;i++) + { + for(j=0;j<13;j++){ + Card temp(j,i); + deck.push_back(temp); + + } + + + } +} +void Doc::shuffle() +{ + vector temp; + int j=0,i; + for(i=0;i<52;i++){ + temp.push_back(i); + } + std::random_shuffle(temp.begin(), temp.end()); + for(i=0;i<52;i++){ + j=i+1; + swap(deck[temp[i]],deck[temp[j]]); + i++; + } + + +} +void Doc::dealCards() +{ + + cout<=52) + return false; + else + return true; +} From 777148f9717f4b02a943ee305cc6c0a902361121 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:10:23 +0800 Subject: [PATCH 21/26] Create Ex09_23.cpp This is my assigment_04 Student ID:201816040112 --- 201816040112/Ex09_23/Ex09_23.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 201816040112/Ex09_23/Ex09_23.cpp diff --git a/201816040112/Ex09_23/Ex09_23.cpp b/201816040112/Ex09_23/Ex09_23.cpp new file mode 100644 index 00000000..b3a1348e --- /dev/null +++ b/201816040112/Ex09_23/Ex09_23.cpp @@ -0,0 +1,15 @@ +#include +#include "Card.h" +#include "DeckOfCards.h" +#include +using namespace std; + +int main() +{ + Doc mycard; + mycard.shuffle(); + while(mycard.moreCards()==true){ + mycard.dealCards(); + } + return 0; +} From 7c1d00afa13d12c33b0b8de3250cb951b7f02e6b Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:10:39 +0800 Subject: [PATCH 22/26] Delete Card.cpp --- 201816040112/Ex09_23.cpp/Card.cpp | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 201816040112/Ex09_23.cpp/Card.cpp diff --git a/201816040112/Ex09_23.cpp/Card.cpp b/201816040112/Ex09_23.cpp/Card.cpp deleted file mode 100644 index a87f5588..00000000 --- a/201816040112/Ex09_23.cpp/Card.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "Card.h" - - -Card::Card(int a,int b) -{ - face=a; - suit=b; -} -string Card::toString() -{ - string res=""; - res=color[suit]+" "+number[face]; - return res; -} From 3549763c0e25d258a537d146c01af8b2fe29cbbf Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:10:48 +0800 Subject: [PATCH 23/26] Delete Card.h --- 201816040112/Ex09_23.cpp/Card.h | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 201816040112/Ex09_23.cpp/Card.h diff --git a/201816040112/Ex09_23.cpp/Card.h b/201816040112/Ex09_23.cpp/Card.h deleted file mode 100644 index 7775d3ae..00000000 --- a/201816040112/Ex09_23.cpp/Card.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef CARD_H_INCLUDED -#define CARD_H_INCLUDED - -#include -using namespace std; -class Card -{ - friend class Doc; -public: - explicit Card(int,int); - string toString(); -private: - int face,suit; - - string number[13]={"1","2","3","4","5","6","7","8","9","10","11","12","13"}; - string color[4]={"Spade","Heart","Diamond","Club"}; - - - - -}; - - -#endif // CARD_H_INCLUDED From aeb44b59fedfbb63b967b361c4a7401ca9c080a7 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:10:56 +0800 Subject: [PATCH 24/26] Delete DeckofCards.cpp --- 201816040112/Ex09_23.cpp/DeckofCards.cpp | 49 ------------------------ 1 file changed, 49 deletions(-) delete mode 100644 201816040112/Ex09_23.cpp/DeckofCards.cpp diff --git a/201816040112/Ex09_23.cpp/DeckofCards.cpp b/201816040112/Ex09_23.cpp/DeckofCards.cpp deleted file mode 100644 index 17d629e2..00000000 --- a/201816040112/Ex09_23.cpp/DeckofCards.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "Card.h" -#include "DeckOfCards.h" -#include -#include -#include -#include -Doc::Doc() -{ - int i,j; - for(i=0;i<4;i++) - { - for(j=0;j<13;j++){ - Card temp(j,i); - deck.push_back(temp); - - } - - - } -} -void Doc::shuffle() -{ - vector temp; - int j=0,i; - for(i=0;i<52;i++){ - temp.push_back(i); - } - std::random_shuffle(temp.begin(), temp.end()); - for(i=0;i<52;i++){ - j=i+1; - swap(deck[temp[i]],deck[temp[j]]); - i++; - } - - -} -void Doc::dealCards() -{ - - cout<=52) - return false; - else - return true; -} From ff0037a663db04906d2afd7c8a6ec987ffb65873 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:11:04 +0800 Subject: [PATCH 25/26] Delete DeckofCards.h --- 201816040112/Ex09_23.cpp/DeckofCards.h | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 201816040112/Ex09_23.cpp/DeckofCards.h diff --git a/201816040112/Ex09_23.cpp/DeckofCards.h b/201816040112/Ex09_23.cpp/DeckofCards.h deleted file mode 100644 index 4098df52..00000000 --- a/201816040112/Ex09_23.cpp/DeckofCards.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef DECKOFCARDS_H_INCLUDED -#define DECKOFCARDS_H_INCLUDED -#include "Card.h" -#include -class Doc -{ -public: - explicit Doc(); - void shuffle(); - vector deck; - bool moreCards(); - void dealCards(); - -private: - int currentCard; - int k=0; - - -}; - - -#endif // DECKOFCARDS_H_INCLUDED From aa3644e1471d50cfb80e3e6151faf6710ab4fe02 Mon Sep 17 00:00:00 2001 From: zifeiyu-c <56395947+zifeiyu-c@users.noreply.github.com> Date: Sun, 10 Nov 2019 16:11:11 +0800 Subject: [PATCH 26/26] Delete Ex09_23.cpp --- 201816040112/Ex09_23.cpp/Ex09_23.cpp | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 201816040112/Ex09_23.cpp/Ex09_23.cpp diff --git a/201816040112/Ex09_23.cpp/Ex09_23.cpp b/201816040112/Ex09_23.cpp/Ex09_23.cpp deleted file mode 100644 index b3a1348e..00000000 --- a/201816040112/Ex09_23.cpp/Ex09_23.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include "Card.h" -#include "DeckOfCards.h" -#include -using namespace std; - -int main() -{ - Doc mycard; - mycard.shuffle(); - while(mycard.moreCards()==true){ - mycard.dealCards(); - } - return 0; -}