Skip to content
Open
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: 12 additions & 5 deletions Pet.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@ public String getSpecies() {

// Main method to test the class
public static void main(String[] args) {
// Create a Pet object
Pet pet1= new Pet("Buddy", "Dog");
// Create Pet objects
Pet pet1 = new Pet("Buddy", "Dog");
Pet pet2 = new Pet("Quackers", "Duck");
Pet petHG = new Pet("Waffle", "Cat");
Pet pet5= new Pet("Joey", "Turtle");
Pet pet3 = new Pet("Quackers", "Duck");
Pet pet4 = new Pet("Barking", "Human");
Pet pet5 = new Pet("Joey", "Turtle");
Pet pet3 = new Pet("Quackers", "Duck");

// Add a new pet
Pet pet6 = new Pet("Speedy", "Snail");

// Print the name of the pet
// Print the names of the pets
System.out.println("Pet's name is: " + pet1.getName());
System.out.println("The second pet's name is: " + pet2.getName());
System.out.println("The cat's name is: " + petHG.getName());
System.out.println("The fourth pet's name is: " + pet4.getName());
System.out.println("The snail's name is: " + pet6.getName());
}
}

// What this code does: This code defines a Pet class that represents a pet with two properties:
// 1. name: A String representing the name of the pet.
// 2. species: A String representing the type of species the pet belongs to (e.g., dog, duck, etc.).