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

CompSci 308 Lab RPS, blc14 & aj168 #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
110 changes: 95 additions & 15 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,121 @@ CompSci 308 : RPS Design
Initial Design
=======

###Class 1
###Class 1: Game

* Bullets are made with asterisks
* Contains Player and WeaponList objects

1. You can also order things with numbers
* Contains methods that:

1. Reads an input file that includes a list of weapons and what each beats

###Class 2
2. Initializes players by creating a new instance of Player class

3. Starts a new game between two players

4. Allows players to choose their weapon, which is stored in that Player's player.weapon

5. Plays a round between two players by checking the players' weapon matchup in a WeaponList outcome matrix and increments the winner's score


###Class 2: Player

* Contains the name, score, and weapon choice of a player

* Contains methods that:

1. Resets the score of the player

2. Increments the score of the player

3. Sets the weapon the player will use


###Class 3: WeaponList

* Contains a list of weapons and an outcome matrix of all the different pairings of weapons

* Contains methods that:

1. Adds a new weapon to the list of weapons and updates the outcome matrix based on a set of the weapons it beats


CRC Design
=======

###Class 1
###Class 1: Game

* Player player1

* Player player2

* WeaponList wl


* newGame() -> returns void

* initializePlayer(String name) ->returns Player

###Class 2
* readFile(File f) -> returns WeaponList

You can add images as well:
* playRoundAndUpdateScore(Player player1, Player player2) -> returns void

![This is cool, too bad you can't see it](crc-example.png "Our CRC cards")
* chooseWeapon(Player player) -> returns void


###Class 2: Player

* String name

* int score

* String weapon



* resetScore() -> returns void

* incrementScore() -> returns void

* setWeapon(String w) -> returns void


###Class 3: WeaponList

* ArrayList<String> weapons

* ArrayList<ArrayList<Integer>> outcomeMatrix


* addWeapon(string Weapon, Set<String> thingsItBeats) -> returns void


Use Cases
=======
To create a new player:

```java
public void initializePlayer(String name) {
Player player1 = new Player();
player1.name = name;
player1.score = 0;
return;
```

You can put blocks of code in here like this:
To add weapon and update relationships:
```java
public int getTotal (Collection<Integer> data) {
int total = 0;
for (int d : data) {
total += d;
addWeapon(string newWeapon, Set<String> thingsItBeats) {
weapons.add(newWeapon);
outcomeMatrix.add(new ArrayList<Integer>);
for (int i = 0; i < weapons.size(); i++) {
if thingsItBeats.contains(weapons.get(i)) {
outcomeMatrix.get(outcomeMatrix.size()-1]).get(i) = 1;
outcomeMatrix.get(i).add(-1);
}
else {
outcomeMatrix.get(outcomeMatrix.size()-1]).get(i) = -1;
outcomeMatrix.get(i).add(1);
}
}
return total;
}
```