Skip to content

Instantly share code, notes, and snippets.

@joncancode
Last active May 9, 2019 14:10
Show Gist options
  • Save joncancode/1222587395b1f457e0fe673551dfdccf to your computer and use it in GitHub Desktop.
Save joncancode/1222587395b1f457e0fe673551dfdccf to your computer and use it in GitHub Desktop.
// Create an HTML file (with all your JavaScript wrapped in a script tag) and then copy the below:
// 1. Suppose that we wanted to create a browser-based calendar program for keeping track of things. In comments, list at least three reasonable abstractions that you might use to build this program; for each abstraction, list out at least two properties and behaviors that it would make sense for that abstraction to have. Below is an example - please write your answer in the same format.
// 'Car'
// Description: Our app manages car sales.
// Every 'car' has
// - a make
// - a model
// - a year
// Every 'car' can
// - drive
// - brake
// - park
// Answer Starts Here
// Answer Ends Here
// 2. Create an Object literal that lines up with the following description. Store it in the variable 'pet_owner', below. Be sure to give it reasonable values for each of its properties.
// 'Owner'
// Description: We are making an app for a veterinary clinic - it manages pets' vaccinations.
// Every 'owner' has:
// - a name
// - an address
let pet_owner;
// Answer Starts Here
// Answer Ends Here
// 3. Create an Object literal that lines up with the following description. Store it in the variable `some_pet`, below.
// Pet
// Description: We are making an app for a veterinary clinic - it manages pets' vaccinations.
// Every 'pet' has:
// - a name
// - a species
// - a breed
// - a noise that it can make (e.g. 'bark', 'meow', etc.)
// Every pet can:
// - make noise (each pet makes its own unique noise, as specified by `noise`.
let some_pet;
// Answer Starts Here
// Answer Ends Here
// 4. Create a constructor function for Pet objects, as described above. The constructor function should be responseible for setting
// the values of `name`, `species`, `breed`, and `noise`. The constructor function should also give each pet a method called `makeNoise`,
// which behaves as described in Q3.
let Pet;
// Answer Starts Here
// Answer Ends Here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment