-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Coding lesson 07 object and test file
- Loading branch information
“Kyvon
authored and
“Kyvon
committed
Mar 19, 2024
1 parent
adfd87d
commit 6faf57e
Showing
2 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
lesson_07/objects/objects_app/src/main/kyvonthompson/Frog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.codedifferently.lesson7.kyvonthompson; | ||
|
||
|
||
|
||
public class frog { | ||
//Frog Attributes | ||
|
||
private String color; | ||
private int age; //Age in years | ||
private int size; //Size in inches | ||
private double weight; //Weigh in pounds | ||
private String breed; | ||
|
||
//Constructer to create brand new frogger | ||
public frog(String color, int age, int size, double weight, String breed) { | ||
|
||
this.color = color; | ||
this.age = age; | ||
this.size = size; | ||
this.weight = weight; | ||
this.breed = breed; | ||
|
||
} | ||
public enum frogColor { | ||
GREEN, | ||
BLUE, | ||
RED, | ||
PURPLE, | ||
PINK, | ||
WHITE, | ||
BROWN, | ||
} | ||
|
||
public enum frogType { | ||
TREE_FROG, | ||
BULLFROG, | ||
POISON_DART_FROG, | ||
LEOPARD_FROG, | ||
COMMON_FROG, | ||
GLASS_FROG | ||
} | ||
// Behaviors of a Frog | ||
|
||
// The frog jumps | ||
public void jump() { | ||
System.out.println("The " + color + " frog jumps!"); | ||
} | ||
|
||
// The frog croaks | ||
public void croak() { | ||
System.out.println("The " + color + " frog says: Croak!"); | ||
} | ||
|
||
// Getter for color | ||
public String getColor() { | ||
return color; | ||
} | ||
|
||
// Setter for color | ||
public void setColor(String color) { | ||
this.color = color; | ||
} | ||
|
||
// Getter for size | ||
public int getSize() { | ||
return size; | ||
} | ||
|
||
// Setter for size | ||
public void setSize(int size) { | ||
this.size = size; | ||
} | ||
|
||
// Getter for age | ||
public int getAge() { | ||
return age; | ||
} | ||
|
||
// Setter for age | ||
public void setAge(int age) { | ||
this.age = age; | ||
} | ||
// Getter for weight | ||
public double getWeight() { | ||
return weight; | ||
} | ||
// Setter for weight | ||
public void setWeight(double weight) { | ||
this.weight = weight; | ||
} | ||
// Getter for breed | ||
public String getBreed(){ | ||
return breed; | ||
} | ||
// Setter for breed | ||
public void setBreed(String breed){ | ||
this.breed = breed; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...bjects/objects_app/src/test/java/com/codedifferently/lesson7/kyvonthompson/Frog test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.codedifferently.lesson7.kyvonthompson; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
|
||
public class Frog { | ||
|
||
public Frog(String string, int i, int j, double d, String string2) { | ||
|
||
|
||
|
||
@Test | ||
// Frog actions | ||
public void testjump() { | ||
|
||
// Creating a new Frog instance | ||
Frog frog = new Frog("green", 5, 2, 8.2, "bulletFrog"); | ||
// Getting frog details | ||
assertEquals("The green frog jumps!", frog.jumps()); | ||
} | ||
|
||
private Frogtest jumps() { | ||
throw new UnsupportedOperationException("Unimplemented method 'jumps'"); | ||
} | ||
} | ||
// System.out.println( | ||
// "frog details: Color - " | ||
// + frog.getColor() | ||
// + ", Size - " | ||
// + frog.getSize() | ||
// + ", Age - " | ||
// + frog.getAge() | ||
// + ",Weight - " | ||
// + frog.getWeight() | ||
// + ",Weight" | ||
// + frog.getBreed()); |