This is my virtual pet project for Manchester Codes as part of the Programming Fundamentals module.
This program allows you to create a virtual pet, be sure to look after it!
- Create your own pet
- You can give them a name
- They can get older
- As they get older, they get hungrier and less fit
- You can walk your pet to increase it's fitness
- You can feed your pet to decrease it's hunger
- You can talk to your pet to see if it needs feeding or walking
- If your pet gets too hungry or unfit, it will DIE
- If your pet ages to 30, it will DIE
- Node JS - to run the program as per the instructions.
Currently none.
- Jest - used for unit testing.
- Open up your terminal and clone the repository onto your local machine using
git clone
, or fork it if you wish and then rungit clone
. - Navigate into the directory that you cloned the repository into (
cd virtual-pet
if you didn't specify a directory). - Enter the Node REPL via the
node
command. - Import the required modules like so:
const { Pet, BabyPet} = require('./src/pet.js')
. - Create your pet! e.g.
const fido = new Pet('Fido');
. - Once you have created your pet, you have access to several methods:
growUp()
walk()
feed()
checkUp()
haveBaby(<babyName>)
This program was built using TDD. More specifically, using red/green refactoring with Jest.
Each function was first written as a failing test, which was then built out as per the test assertions and later refactored, and tested again.
All tests are located inside of the __tests__
directory, and if you wish to run them, you can install Jest by running npm install
. From there, you can run npm test
to run the tests.
Refactor to allow forMIN_HUNGER
,MAX_HUNGER
etc. to make code more readable.Allow pets to have babies!Convert to ES6 Class Syntax.
This project is licensed under the MIT license.