Welcome to the Bird Simulation Project. This program models a real-world object, a Bird, using Java classes. The project demonstrates object-oriented programming principles such as encapsulation, composition, constructors, method overloading, and behaviors.
This Java program simulates the behavior of birds in a virtual environment. Users can create birds, feed them, make them fly, and monitor their health and energy levels. The project highlights key object-oriented programming principles, including encapsulation, composition, constructors, and method overloading.
The workspace contains the following folders:
src: contains the Java source files (Bird.java,Wing.java,BirdTester.java)lib: contains any dependencies if addedbin: the folder where compiled.classfiles are generated by default
If you want to customize the folder structure, open .vscode/settings.json and update the related settings there.
- https://drive.google.com/file/d/1vTpRkEbA0jwmoYEUqjW-5yVHbANm0T2l/view?usp=sharing
- PLease check this Flowchart for more detailed information
Represents the main class for the bird object. Includes:
- Six instance variables (
color,size,weight,energyLevel,health, andwing) - Two constructors (default and parameterized)
- Accessor and mutator methods for all variables
- Four behavior methods (
fly(),eat(double),heal(),displayStatus()) - A
toString()method for displaying information about the bird
Represents the secondary class used within the Bird class. Includes:
- One instance variable (
wingStrength) - Accessor and mutator methods
- A
toString()method for descriptive output
Contains the main() method used to test the Bird and Wing classes.
Demonstrates:
- Object creation using both constructors
- Calling behavior methods with and without parameters
- Printing the object’s state using
toString()
-
Open the project folder in Visual Studio Code.
-
Compile the Java files:
javac -d bin src/*.java -
Run the tester class:
java -cp bin BirdTester
Bird [color = unknown, size = 0.0, weight = 0.0, energyLevel = 100.0, health = 100.0, wingStrength = 50.0]
Bird [color = Blue, size = 1.5, weight = 2.3, energyLevel = 80.0, health = 90.0, wingStrength = 70.0]
The bird has eaten and gained energy.
The bird has eaten and gained energy.
The bird is flying!
The bird is flying!
Bird Status: Bird [color = unknown, size = 0.0, weight = 0.0, energyLevel = 110.0, health = 95.0, wingStrength = 50.0]
Bird Status: Bird [color = Blue, size = 1.5, weight = 2.3, energyLevel = 85.0, health = 85.0, wingStrength = 70.0]
- Write and call constructors, including overloaded constructors.
- Write methods with parameters and return values.
- Write and use custom classes in Java.
The JAVA PROJECTS view in Visual Studio Code allows you to manage dependencies. More details can be found in the VS Code Java Dependency Guide.