Bees (the most noble of insects) progress through specific developmental stages over the course of their lifetimes. Each phase has specific traits and behaviors associated with it that are unique to that lifestage. In this repo, you will create bees of many lifestages while practicing the class syntax, instatiation, inheritance, and subclassing in Typescript.
.
├── Grub
│ └── Bee
│ ├── HoneyMakerBee
│ └── ForagerBee
│ └── RetiredForagerBee
As you can see in the diagram above, all bees start out as a Grub, grow into a Bee and are then assigned its specific jobs and tasks among its other charactersitics. This means that characteristics are inherited from the classes above (although they can be modified on the current class level).
- After you fork and clone, run
npm installis run from the command line to install all the project dependencies
The ECMAScript specification is a scripting language specification upon which JavaScript implementations (such as those found in web browsers like Chrome) are based. In June 2015, the 6th edition of the ECMAScript standard was finalized, and is commonly referred to as ES6.
ES6 introduces a wealth of new features to JavaScript while being entirely reverse-compatible with older JavaScript.
One exciting feature is the inclusion of a class keyword! This is a big change for engineers who write object-oriented code because it makes JavaScript look and feel more like a traditional class based language even though it's really just syntactic sugar. ES6 makes subclassing much easier as well with the introduction of the extends keyword. This sprint is designed to get you comfortable with this new instantiation pattern.
Build your first class in Grub.js. Grub will act as the superclass for all other types of bees. Work through the repo in the order specified below, making sure to pass all of the specs in test/index.html - which you should open in your browser when you run npm test.
- This assignment must be written with TypeScript classes by using the
class,extends, andsuperkeywords - Although there are multiple tests for each class, you will only be able to see one test at a time. As soon as one test fails the spec runner stops running and you must pass the current test to continue.
- Create a Grub class in TypeScript with:
- an
ageproperty that is set to0 - a
colorproperty that is set topink - a
foodproperty that is set tojelly - an
eatmethod that returns'Mmmmmmmmm jelly'
- an
- Create a Bee class in TypeScript with:
- the Grub superclass
- an
ageproperty that is set to5 - a
colorproperty that is set toyellow - a
foodproperty that is inherited from grub - an
eatmethod that is inherited from grub - a
jobproperty that is set toKeep on growing
- Create a HoneyMakerBee class in TypeScript with:
- the Bee superclass
- an age property that is set to
10 - a job property that is set to
make honey - a color property inherited from
beethat is set toyellow - a food property that is inherited from grub
- an eat method that is inherited from grub
- a
honeyPotproperty that is set to0 - a
makeHoneymethod that adds1to that honeyBee'shoneyPot - a
giveHoneymethod that subtracts1from that honeyBee'shoneyPot
- Create a ForagerBee class in TypeScript with:
- the Bee superclass
- an age property that is set to
10 - a
jobproperty that is set tofind pollen - a
colorproperty inherited frombeethat is set toyellow - a
foodproperty that is inherited from grub - an
eatmethod that is inherited from grub - a
canFlyproperty that is settrue - a
treasureChestproperty that is set to an empty array[] - a
foragemethod that allows the bee to add atreasureto thetreasureChest
- Create a RetiredForagerBee class in TypeScript with:
- the ForagerBee superclass
- an
ageproperty that is set to40 - a
jobproperty that is set togamble - a
canFlyproperty that is set tofalse - a
colorproperty that is set togrey - a
foragemethod that returnsI am too old, let me play cards instead - a
foodproperty that is inherited from grub - an
eatmethod that is inherited from grub - a
treasureChestproperty inherited from ForagerBee that is set to an empty array[] - an always winning
gamblemethod that allows the bee to add atreasureto thetreasureChest