Fix: 1
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package PrepSession;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package PrepSession;
|
||||
|
||||
public interface Attack {
|
||||
void Attacking();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package PrepSession;
|
||||
|
||||
public abstract class Breed {
|
||||
|
||||
public abstract void Breeding();
|
||||
|
||||
int lifeNum = 1;
|
||||
String enviroment = "home";
|
||||
|
||||
public void Mating() {
|
||||
System.out.println("Male and Female has to mate");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package PrepSession;
|
||||
|
||||
public class Eagle extends Breed implements Attack{
|
||||
public static void main(String[] args) {
|
||||
Eagle eagle = new Eagle();
|
||||
System.out.println(eagle.lifeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Attacking() {
|
||||
System.out.println("The Eagle is going crazy and I can't fucking find his prey.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Breeding() {
|
||||
System.out.println("Breeding through laying eggs... Oviparous");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package PrepSession;
|
||||
|
||||
public class Fish extends Breed implements Hide, Attack{
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Hiding() {
|
||||
System.out.println("The fish is going deeper to hide from the Eagle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Attacking() {
|
||||
System.out.println("The fish attacked a smaller fish");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Breeding() {
|
||||
System.out.println("Breeding through laying eggs... Oviparous");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package PrepSession;
|
||||
|
||||
public interface Hide {
|
||||
void Hiding();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package PrepSession;
|
||||
|
||||
public class MainClass {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Fish fish = new Fish();
|
||||
fish.Hiding();
|
||||
fish.Attacking();
|
||||
fish.Breeding();
|
||||
System.out.println("");
|
||||
|
||||
Rabbit rabbit = new Rabbit();
|
||||
rabbit.Hiding();
|
||||
rabbit.Mating();
|
||||
rabbit.Breeding();
|
||||
System.out.println("");
|
||||
|
||||
Eagle hawk = new Eagle();
|
||||
hawk.Attacking();
|
||||
hawk.Mating();
|
||||
hawk.Breeding();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package PrepSession;
|
||||
|
||||
public class Rabbit extends Breed implements Hide{
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Hiding() {
|
||||
System.out.println("The Rabbit is running like crazy to hide.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Breeding() {
|
||||
System.out.println("Breeding by having small baby rabbits... Mammals");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package PrepSession;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package PrepSession;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class EagleTestCase {
|
||||
@Test
|
||||
public void Eagle_testATTACK(){
|
||||
Eagle hawk = new Eagle();
|
||||
ByteArrayOutputStream eagAttack = new ByteArrayOutputStream();
|
||||
System.setOut(new PrintStream(eagAttack));
|
||||
hawk.Attacking();
|
||||
assertEquals("The Eagle is going crazy and I can't fucking find his prey.\n", eagAttack.toString());
|
||||
assertEquals(1, hawk.lifeNum);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package PrepSession;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class FishTestCase {
|
||||
// Fish hides successfully
|
||||
@Test
|
||||
public void test_fish_hides_successfully() {
|
||||
Fish fish = new Fish();
|
||||
// Assuming the output is checked via console output, we can use System.out to capture it.
|
||||
// This is a simple example, in real scenarios, we might use a logging framework or mock the output.
|
||||
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||
System.setOut(new PrintStream(outContent));
|
||||
fish.Hiding();
|
||||
assertEquals("The fish is going deeper to hide from the Eagle\n", outContent.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_fishAttack(){
|
||||
Fish fish = new Fish();
|
||||
ByteArrayOutputStream attckOut = new ByteArrayOutputStream();
|
||||
System.setOut(new PrintStream(attckOut));
|
||||
fish.Attacking();
|
||||
assertEquals("The fish attacked a smaller fish\n", attckOut.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package PrepSession;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class RabbitTestCase {
|
||||
@Test
|
||||
public void Rabbit_TestCase(){
|
||||
Rabbit rabbit = new Rabbit();
|
||||
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||
System.setOut(new PrintStream(outContent));
|
||||
rabbit.Hiding();
|
||||
assertEquals("The Rabbit is running like crazy to hide.\n", outContent.toString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user