Skip to content

Working on tests #67

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

Open
wants to merge 1 commit 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
17 changes: 17 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/Cat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.zipcoder.polymorphism;

public class Cat extends Pet{
public Cat(String name) {
super(name);
}

public Cat() {

}

@Override
public String speak() {
super.speak();
return null;
}
}
20 changes: 20 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/Dog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.zipcoder.polymorphism;

public class Dog extends Pet{

public Dog(String name) {
super(name);
}

public Dog() {

}

@Override
public String speak() {
super.speak();
return null;
}


}
18 changes: 18 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/Lion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.zipcoder.polymorphism;

public class Lion extends Pet{

public Lion(String name) {
super(name);
}

public Lion() {

}

@Override
public String speak() {super.speak();
String sound = "Rawr";
return sound;
}
}
12 changes: 12 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/MainApplication.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
package io.zipcoder.polymorphism;

public class MainApplication {
public static void main(String[] args){
Pet myPet = new Pet();
Pet myCat = new Cat();
Pet myDog = new Dog();
Pet myLion = new Lion();
myPet.speak();
myCat.speak();
myDog.speak();
myLion.speak();
// would these methods be better in main method or pet method?

}
}
30 changes: 30 additions & 0 deletions src/main/java/io/zipcoder/polymorphism/Pet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.zipcoder.polymorphism;

public class Pet{
public Pet(String name) {
this.name = name;
}

public Pet() {

}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

String name;

public String speak(){


return null;
}



}
9 changes: 9 additions & 0 deletions src/test/java/io/zipcoder/polymorphism/CatTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.zipcoder.polymorphism;

import junit.framework.TestCase;

public class CatTest extends TestCase {



}
9 changes: 9 additions & 0 deletions src/test/java/io/zipcoder/polymorphism/DogTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.zipcoder.polymorphism;

import junit.framework.TestCase;

public class DogTest extends TestCase {

public void testSpeak() {
}
}
21 changes: 21 additions & 0 deletions src/test/java/io/zipcoder/polymorphism/LionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.zipcoder.polymorphism;

import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;

public class LionTest extends TestCase {

@Test
public void testSpeak(){
//Give
Lion lion = new Lion("Im Lion Benny");
//When
String expected = "Rawr";
String actual = lion.speak();
//Then
Assert.assertEquals(expected,actual);

}

}
15 changes: 15 additions & 0 deletions src/test/java/io/zipcoder/polymorphism/PetTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.zipcoder.polymorphism;

import junit.framework.TestCase;

public class PetTest extends TestCase {

public void testTestGetName() {
}

public void testTestSetName() {
}

public void testSpeak() {
}
}