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

Vt111 #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
46 changes: 46 additions & 0 deletions src/main/java/Orc.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
public class Orc implements Tradable, Domesticatable {
int toes;
private String[] armor;
private String[] weapon;

public Orc(){
this.armor = new String[0];
this.weapon = new String[0];
toes = 1;
}
@Override
public String sound() {
return "growl";
}

@Override
public int getPrice() {
return 50;
}

public void upgrade_armor(String item){
String[] jk = new String[armor.length+1];
for(int i = 0; i < jk.length; i++){
jk[i] = armor[i];
}
jk[armor.length] = item;
armor = jk;
}
public void upgrade_weapon(String item){
String[] lm = new String[weapon.length+1];
for(int i = 0; i < lm.length; i++){
lm[i] = weapon[i];
}
lm[weapon.length] = item;
weapon = lm;
}

public String[] getArmor(){
return armor;
}

public String[] getWeapon(){
return weapon;
}

}
4 changes: 3 additions & 1 deletion src/main/java/Trader.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public static void main(String[] args) {
List<Tradable> all_items = Arrays.asList(
new Horse(),
new Horse(),
new Horse()
new Horse(),
new Orc(),
new Orc()
// TODO: Add Tradable objects here!
);

Expand Down
24 changes: 24 additions & 0 deletions src/test/java/OrcTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import org.junit.*;

import static org.junit.Assert.*;


public class OrcTest {
Orc o;

@Before
public void setUp() throws Exception {
o = new Orc();
}

@Test(timeout = 50)
public void TestSound() {
assertEquals("growl", o.sound());
}

@Test(timeout = 50)
public void TestGetPrice() {
assertEquals(50, o.getPrice());
}

}