Skip to content
Open
Show file tree
Hide file tree
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
122 changes: 92 additions & 30 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,106 @@ CompSci 308 : RPS Design
> This is the link to the Lab Description:
[Lab - RPS](http://www.cs.duke.edu/courses/compsci308/spring16/classwork/02_design_rps/index.php)

Initial Design
=======
#Class one
WeaponSystem- holds the database of weapon relations, compares 2 weapons against eachother, updates the database to allow for enw weapons
###Methods

###Class 1
Makemap- pass in file, return map containing how weaons relate to eachother

* Bullets are made with asterisks
update-accepts text, appends file, and makes new map of weapon relations

1. You can also order things with numbers
isBeaten-accepts two strings that are weapon names, returns a boolean to see which weapon beats which using the makeMap method

#Class 2
Player Class
identifies player, allowes weapon choice, keeps score

###Class 2
has properties payerid score, and weapon

###Methods
Chooseweapon-prompts the player to choose a weapon

#Class 3
Game
Executes the game,
Start(asks player for id and file to pass into weapons system class), returns nothing

CRC Design
=======
GameLoop-
asks the player to choose weapon from Player class
sees which player won, increments score

###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<Integer> data) {
int total = 0;
for (int d : data) {
total += d;
}
return total;
}
package lab_rps;

public class Player {
private String id;
private int score;
private String weopon;
public Player(String id) {
this.id = id;
}
public void chooseWeapon() {
//prompts to choose
String weapon = ""; //this has whatever was user input
this.weopon = weapon;
}

}
```

```java
package lab_rps;

import java.util.HashMap;
import java.util.List;

public class WeaponSystem {
HashMap<String, List<String>> map;
List<String> fileTxt;
public WeaponSystem(String txt) {
//do some file input stuff
//parseStuff
//call makeMap
//put stuff in file too
}
public boolean isBeaten(String a, String b) {
return map.get(a).contains(b);
}
public void makeMap(String txt) {
//parse file
//put in map
}
public void update(String txt) {
//adds stuff from new file to fileText

}
}
```
```java
package lab_rps;

import java.util.*;

public class rpsGame {
public static void main(String args[]) {
rpsGame r = new rpsGame();
r.start();
Player a = new Player("id1");
Player b = new Player("id2");
WeaponSystem w = new WeaponSystem("");
while(true) {
a.chooseWeapon();
b.chooseWeapon();
if(!a.weapon.equals(b.weapon)){
w.isBeaten(a.weapon, b.weapon);
//choose if to continue
//add scores...
}

}
}
private void start() {
//call player to enter id
//choose list of weapons which is passed to weopons system
}
}
```
16 changes: 16 additions & 0 deletions src/lab_rps/Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package lab_rps;

public class Player {
private String id;
private int score;
private String weopon;
public Player(String id) {
this.id = id;
}
public void chooseWeapon() {
//prompts to choose
String weapon = ""; //this has whatever was user input
this.weopon = weapon;
}

}
26 changes: 26 additions & 0 deletions src/lab_rps/WeaponSystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package lab_rps;

import java.util.HashMap;
import java.util.List;

public class WeaponSystem {
HashMap<String, List<String>> map;
List<String> fileTxt;
public WeaponSystem(String txt) {
//do some file input stuff
//parseStuff
//call makeMap
//put stuff in file too
}
public boolean isBeaten(String a, String b) {
return map.get(a).contains(b);
}
public void makeMap(String txt) {
//parse file
//put in map
}
public void update(String txt) {
//adds stuff from new file to fileText

}
}
27 changes: 27 additions & 0 deletions src/lab_rps/rpsGame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package lab_rps;

import java.util.*;

public class rpsGame {
public static void main(String args[]) {
rpsGame r = new rpsGame();
r.start();
Player a = new Player("id1");
Player b = new Player("id2");
WeaponSystem w = new WeaponSystem("");
while(true) {
a.chooseWeapon();
b.chooseWeapon();
if(!a.weapon.equals(b.weapon)){
w.isBeaten(a.weapon, b.weapon);
//choose if to continue
//add scores...
}

}
}
private void start() {
//call player to enter id
//choose list of weapons which is passed to weopons system
}
}