Skip to content

Built and created classes for pets #66

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/Bird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.zipcoder.polymorphism;

public class Bird extends Pets{



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

@Override
public String speak() {
String sound = "chirp";
return sound;

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

public class Cat extends Pets{




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



@Override
public String speak() {
String sound = "meow";
return sound;

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

public class Dog extends Pets{



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


@Override
public String speak() {
String words = "woof";

return words;

}


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

public class MainApplication {

private int numOfPets;
private String[] nameOfPets;

public MainApplication(int numOfPets, String[] nameOhfPets) {
this.numOfPets = numOfPets;
this.nameOfPets = nameOhfPets;
}


public static void main(String[] args) {
System.out.println("How many pets do you have?");
System.out.println("What are the names of your pets?");

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

public class Pets {

private String name;

public Pets(String name) {
this.name = name;
}



public String getName() {
return name;
}

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

public String speak() {
return null;

}




}
40 changes: 40 additions & 0 deletions src/test/java/io/zipcoder/polymorphism/BirdTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.zipcoder.polymorphism;
import org.junit.Assert;
import org.junit.Test;



public class BirdTest {

@Test
public void testSpeak() {
Bird bird = new Bird("Justin the bird");

String expected = "meow";
String actual = bird.speak();

Assert.assertNotEquals(expected, actual);
}
@Test
public void testSpeak2() {
Bird bird = new Bird("Justin the bird");

String expected = "chirp";
String actual = bird.speak();

Assert.assertEquals(expected, actual);
}

@Test
public void testGetName() {

String name = "Justin";
Bird bird = new Bird(name);
String expected = bird.getName();
String actual = name;
Assert.assertEquals(expected, actual);

}


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

public class CatTest {


@Test
public void testSpeak() {
Cat cat = new Cat("Justin the cat");

String expected = "woof";
String actual = cat.speak();

Assert.assertNotEquals(expected, actual);
}
@Test
public void testSpeak2() {
Cat cat = new Cat("Justin the cat");

String expected = "meow";
String actual = cat.speak();

Assert.assertEquals(expected, actual);
}

@Test
public void testGetName() {

String name = "Justin";
Cat cat = new Cat(name);
String expected = cat.getName();
String actual = name;
Assert.assertEquals(expected, actual);

}




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

public class DogTest {

@Test

public void testDogName() {


Dog dog = new Dog("Justin");
String expected = dog.getName();
String actual = "Frank";
Assert.assertNotEquals(expected, actual);

}
@Test
public void testSpeak() {
Dog dog = new Dog("Justin");

String expected = "woof";
String actual = dog.speak();

Assert.assertEquals(expected, actual);
}
@Test
public void testSpeak2() {
Dog dog = new Dog("Justin");

String expected = "";
String actual = dog.speak();

Assert.assertNotEquals(expected, actual);
}





}
35 changes: 35 additions & 0 deletions src/test/java/io/zipcoder/polymorphism/PetsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.zipcoder.polymorphism;
import org.junit.Assert;
import org.junit.Test;

public class PetsTest {

@Test
public void testGetName() {

String name = "Justin";
Pets pet = new Pets(name);
String expected = pet.getName();
String actual = name;
Assert.assertEquals(expected, actual);

}

@Test
public void testGetName2() {


Pets pet = new Pets("Justin");
String expected = pet.getName();
String actual = "Frank";
Assert.assertNotEquals(expected, actual);

}







}