/jurassic_park

Example of TDD in Javascript for Jurassic Park

Primary LanguageJavaScript

Homework: Jurassic Park

Learning Objectives:

  • Be able to use the fundamental JavaScript language features and data types;
  • Be able to create an application using multiple interacting objects.

Brief

John Hammond has tasked you with creating an app to help him manage his theme park. He needs to be able to track and manage information about the various dinosaurs in his park and the number of visitors that they will attract.

MVP

A dinosaur must have:

  • A species;
  • A diet (e.g. carnivore, herbivore or omnivore);
  • An average number of visitors attracted per day;

A park must have:

  • A name;
  • A ticket price;
  • A collection of dinosaurs.

A park must be able to:

  • Add a dinosaur to its collection of dinosaurs;
  • Remove a dinosaur from its collection of dinosaurs;
  • Find the dinosaur that attracts the most visitors;
  • Find all dinosaurs of a particular species;
  • Calculate the total number of visitors per day;
  • Calculate the total number of visitors per year;
  • Calculate the total revenue from ticket sales for one year.

Extensions

A park must be able to:

  • Remove all dinosaurs of a particular species;
  • Provide an object containing each of the diet types and the number of dinosaurs in the park of that diet type: { 'carnivore': 5, 'herbivore': 2, 'omnivore': 1 }