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
2 changes: 2 additions & 0 deletions Zoo/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/main/
/model/
Binary file modified Zoo/bin/main/Runner.class
Binary file not shown.
Binary file modified Zoo/bin/model/Example.class
Binary file not shown.
7 changes: 7 additions & 0 deletions Zoo/src/main/Runner.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main;

import model.Example;
import model.Raven; // Import the Raven class

public class Runner {

Expand All @@ -13,5 +14,11 @@ private void go() {
Example example = new Example();
example.makeNoise();

// Create a Raven object
Raven raven = new Raven("Mountains", "Common Raven", 24, "Black");
System.out.println("\nRaven:");
System.out.println(raven); // Calls the toString() method implicitly
System.out.println("Noise: " + raven.makeNoise()); // Calls the makeNoise() method

}
}
69 changes: 69 additions & 0 deletions Zoo/src/model/Raven.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package model;

public class Raven {
// Private instance variables to store Raven properties
private String habitat;
private String name;
private int length;
private String featherColor;

// Constructor to initialize Raven object with specified properties
public Raven(String habitat, String name, int length, String featherColor) {
this.habitat = habitat;
this.name = name;
this.length = length;
this.featherColor = featherColor;
}

// Getter method for habitat
public String getHabitat() {
return habitat;
}

// Setter method for habitat
public void setHabitat(String habitat) {
this.habitat = habitat;
}

// Getter method for name
public String getName() {
return name;
}

// Setter method for name
public void setName(String name) {
this.name = name;
}

// Getter method for length
public int getLength() {
return length;
}

// Setter method for length
public void setLength(int length) {
this.length = length;
}

// Getter method for featherColor
public String getFeatherColor() {
return featherColor;
}

// Setter method for featherColor
public void setFeatherColor(String featherColor) {
this.featherColor = featherColor;
}

// Override toString method to provide a string representation of the Raven object
@Override
public String toString() {
return "Raven [name=" + name + ", length=" + length + " inches, habitat=" + habitat +
", featherColor=" + featherColor + "]";
}

// Method to simulate the noise a Raven makes
public String makeNoise() {
return "Caw! Caw!";
}
}