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
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<groupId>io.zipcoder</groupId>
<artifactId>Interfaces</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/io/zipcoder/Application.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
package io.zipcoder;


import java.util.Scanner;

public class Application {

public static void main(String[] args){
Scanner scn = new Scanner(System.in);
String name = "";
/* System.out.println("What is your pets name?");
String petName = scn.nextLine();
System.out.println("Your pets name is " + petName);*/
System.out.println("These are the pets we have available. Koala, Cat, and Dog.");
String animal = scn.next();
switch(animal) {
case "Koala":
while (true){

Koala k = new Koala();

System.out.println("Whats your Koala's name?");
name = scn.next();
System.out.println("They sound like this " + k.speak() + " Your pets name is " + name);
break;
}

}

}

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

public class Cat extends Pets{
String speak = "";
public String speak(){
speak = "meow";
System.out.println(speak);
return speak;
}
}
10 changes: 10 additions & 0 deletions src/main/java/io/zipcoder/Dog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.zipcoder;

public class Dog extends Pets{
String speak = "";
public String speak(){
speak = "bark";
System.out.println(speak);
return speak;
}
}
11 changes: 11 additions & 0 deletions src/main/java/io/zipcoder/Koala.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.zipcoder;

public class Koala extends Pets{
String speak = "";
@Override
public String speak() {
speak = "krrr";
System.out.println(speak);
return speak;
}
}
20 changes: 20 additions & 0 deletions src/main/java/io/zipcoder/Pets.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.zipcoder;

public class Pets {
private String name;
private String speak;

public String speak(){
return speak;
}

public String getName() {
return name;
}

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


}
36 changes: 36 additions & 0 deletions src/test/java/io/zipcoder/ApplicationTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
package io.zipcoder;


import org.junit.Assert;
import org.junit.Test;

import java.util.Scanner;

public class ApplicationTest {
Scanner scn = new Scanner(System.in);
@Test
public void howManyPets(){

}
@Test
public void whatKindOfPet(){


}
@Test
public void speak(){
//Given
Koala k = new Koala();
String speak = "";
//When
//Then
Assert.assertEquals(k.speak, speak);




}

@Test
public void checkingTheInstance(){
Koala koala = new Koala();
Assert.assertTrue(koala instanceof Pets);
}


}