Welcome to the Virtual Pet project! This is a simple program that allows you to create and interact with a virtual pet using JavaScript.
Create your own virtual pet Feed and walk your pet to keep it healthy and happy Track your pet's hunger and fitness levels Pet can age & even die if neglected for too long
Clone this repository to your local machine Make sure you have Node.js installed Install any necessary dependencies by running npm install in the project directory
Run the program by executing npm start in your terminal or command prompt Follow the on-screen instructions to create and interact with your virtual pet
This function makes the pet grow one year older, and increases its hunger and decreases its fitness.
This function takes the pet for a walk, increasing its fitness by 4 (up to a maximum of 10).
This function feeds the pet, decreasing its hunger by 3 (down to a minimum of 0).
This function checks the pet's fitness and hunger levels, and logs a message depending on its needs. If the pet's fitness is below 3 and its hunger is above 5, it needs a walk and is hungry. If its fitness is above 3 and its hunger is below 5, it feels great. If its fitness is below 3 and its hunger is below 5, it needs a walk. If its fitness is above 3 and its hunger is above 5, it is hungry.
This function allows a pet to adopt a child. It adds the name of the child to the pet's children array.
There are several constants that are used throughout the pet functions:
Each pet has the following properties:
Contributions to this project are welcome! If you find a bug or have an idea for a new feature, please open an issue or submit a pull request.
This project was created by Benj Speight. Special thanks to CommandShift for their contributions.