From f7b6455d3bda7170442f31b934b6a0ca91cf8d75 Mon Sep 17 00:00:00 2001 From: ANNIE Date: Thu, 21 Jan 2016 17:44:53 -0500 Subject: [PATCH 1/3] update README.md --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fa03519..d7197ea 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,65 @@ -# lab_rps -Duke CompSci 308 Lab : Design for the game Rock-Paper-Scissors +**lab_rps** +=================== + +akt16, dm269, aaa53 +Annie Tang, Jonathan Ma, Aamir Azhar + +**Cases:** +- A new game is started with two players, their scores are reset to 0. +- A player chooses his RPS "weapon" with which he wants to play for this round. +- Given two players' choices, one player wins the round, and their scores are updated. +- A new choice is added to an existing game and its relationship to all the other choices is updated. +- A new game is added to the system, with its own relationships for its all its "weapons". + + + +Classes +------------- + +MainRPS +> **public void readGame** +> Input: new game data added to system +> Output: void +> Can read in new game here and turn each weapon & relationship within this game to Weapon objects, +> +> **public int getWinner** +> Input: two players +> Output: 1/0 +> calls compareTo method on weapons of player A and B +> two weapons, from getPlayerWeapon +> +>**public void readNewWeapon** +>Input: new weapon choice data +>Output: none, just creates a Weapon option + +Weapon +> **Input:** interactions +> **Output:** usable Weapon object +> +>**public void init** +> Input: interactions +> Output: no return, but creates collection structure +> method to create collection structure from interactions (possibly ArrayList of ArrayLists, i.e. matrix implementation) +> +>**public int compareTo** +> Input: "this" and another weapon +> Output: returns 1/0 based on which weapon wins + +Player +> **Input:** none, i.e. Player A = new Player(); +> **Output:** a player +> +> **public int getScore** +> Input: none +> Output: score of player +> +> **public Weapon getPlayerWeapon** +> Input: no parameters +> Output: player's choice of weapon +> user input here +> +>**public void setScore** +>Input: int +>Output: void + + From b99e27b608602378af11ced84e6d4724c1dc53f0 Mon Sep 17 00:00:00 2001 From: ANNIE Date: Thu, 21 Jan 2016 17:56:10 -0500 Subject: [PATCH 2/3] add Java code to cases --- README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d7197ea..3abd675 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,27 @@ Annie Tang, Jonathan Ma, Aamir Azhar **Cases:** - A new game is started with two players, their scores are reset to 0. +>readGame("datafile1"); +>Player A = new Player(); +>Player B = new Player(); +>A.setScore(0); +>B.setScore(0); + - A player chooses his RPS "weapon" with which he wants to play for this round. +>A.getPlayerWeapon(); + - Given two players' choices, one player wins the round, and their scores are updated. +>if(getWinner(A, B) == 1){ +> A.setScore(A.getScore() + 1); +>} +>else if(getWinner(A, B) == -1){ +> B.setScore(B.getScore() + 1); +>} + - A new choice is added to an existing game and its relationship to all the other choices is updated. +>readNewWeapon(); - A new game is added to the system, with its own relationships for its all its "weapons". +>readGame("datafile2"); @@ -17,14 +34,14 @@ Classes ------------- MainRPS -> **public void readGame** +> **public void readGame(String textfile)** > Input: new game data added to system > Output: void > Can read in new game here and turn each weapon & relationship within this game to Weapon objects, > > **public int getWinner** -> Input: two players -> Output: 1/0 +> Input: two players; ex: getWinner(A,B) +> Output: 1/-1/0, where 1 means A wins, -1 means B wins, 0 is tie. > calls compareTo method on weapons of player A and B > two weapons, from getPlayerWeapon > @@ -43,7 +60,7 @@ Weapon > >**public int compareTo** > Input: "this" and another weapon -> Output: returns 1/0 based on which weapon wins +> Output: returns 1/-1 based on which weapon wins, 0 is tie Player > **Input:** none, i.e. Player A = new Player(); @@ -55,7 +72,7 @@ Player > > **public Weapon getPlayerWeapon** > Input: no parameters -> Output: player's choice of weapon +> Output: player's choice of weapon, is stored in Player class > user input here > >**public void setScore** From c59048ca7c2cbf49dc0af4be1c95d637748a2dc1 Mon Sep 17 00:00:00 2001 From: ANNIE Date: Thu, 21 Jan 2016 17:59:25 -0500 Subject: [PATCH 3/3] update DESIGN.md instead of README --- DESIGN.md | 121 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 43 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index b581809..3abd675 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -1,47 +1,82 @@ -CompSci 308 : RPS Design +**lab_rps** =================== -> This is the link to the Lab Description: -[Lab - RPS](http://www.cs.duke.edu/courses/compsci308/spring16/classwork/02_design_rps/index.php) +akt16, dm269, aaa53 +Annie Tang, Jonathan Ma, Aamir Azhar + +**Cases:** +- A new game is started with two players, their scores are reset to 0. +>readGame("datafile1"); +>Player A = new Player(); +>Player B = new Player(); +>A.setScore(0); +>B.setScore(0); + +- A player chooses his RPS "weapon" with which he wants to play for this round. +>A.getPlayerWeapon(); + +- Given two players' choices, one player wins the round, and their scores are updated. +>if(getWinner(A, B) == 1){ +> A.setScore(A.getScore() + 1); +>} +>else if(getWinner(A, B) == -1){ +> B.setScore(B.getScore() + 1); +>} + +- A new choice is added to an existing game and its relationship to all the other choices is updated. +>readNewWeapon(); +- A new game is added to the system, with its own relationships for its all its "weapons". +>readGame("datafile2"); + + + +Classes +------------- + +MainRPS +> **public void readGame(String textfile)** +> Input: new game data added to system +> Output: void +> Can read in new game here and turn each weapon & relationship within this game to Weapon objects, +> +> **public int getWinner** +> Input: two players; ex: getWinner(A,B) +> Output: 1/-1/0, where 1 means A wins, -1 means B wins, 0 is tie. +> calls compareTo method on weapons of player A and B +> two weapons, from getPlayerWeapon +> +>**public void readNewWeapon** +>Input: new weapon choice data +>Output: none, just creates a Weapon option + +Weapon +> **Input:** interactions +> **Output:** usable Weapon object +> +>**public void init** +> Input: interactions +> Output: no return, but creates collection structure +> method to create collection structure from interactions (possibly ArrayList of ArrayLists, i.e. matrix implementation) +> +>**public int compareTo** +> Input: "this" and another weapon +> Output: returns 1/-1 based on which weapon wins, 0 is tie + +Player +> **Input:** none, i.e. Player A = new Player(); +> **Output:** a player +> +> **public int getScore** +> Input: none +> Output: score of player +> +> **public Weapon getPlayerWeapon** +> Input: no parameters +> Output: player's choice of weapon, is stored in Player class +> user input here +> +>**public void setScore** +>Input: int +>Output: void -Initial Design -======= - -###Class 1 - -* Bullets are made with asterisks - -1. You can also order things with numbers - - -###Class 2 - - - -CRC Design -======= - -###Class 1 - - -###Class 2 - -You can add images as well: - -![This is cool, too bad you can't see it](crc-example.png "Our CRC cards") - - -Use Cases -======= - -You can put blocks of code in here like this: -```java - public int getTotal (Collection data) { - int total = 0; - for (int d : data) { - total += d; - } - return total; - } -```