Skip to content
Alex Li edited this page Feb 8, 2022 · 11 revisions

Specifications

interface User {
  "username" : String, // Unique
  "password" : String, // Hashed password
  "employee": Boolean, // Boolean for whether user is an employee
}
interface Customer extends User {
  "previous_orders": Doughnut[], // List of donuts they've ordered
}; 

interface Drone {
  "id" : Number, // Unique drone ID
  "charge" : Number, // Remaining charge % [0,100]
}

interface Doughnut {
  "name" : String, // Unique doughnut name
  "price" : number, // Price in donutbucks (or whatever the world uses these days)
  "description" : String, // Longer description of doughnut
}

interface Address {
  'street': String,
  'city': String,
  'state': String,
  'zip': String,
}

interface Order {
  "user" : User, // User
  "price" : Number, // Price of all donuts, ±tax.
  "doughnuts" : Doughnut[], // List of ordered doughnuts
  "quantities" : Number[], // Parallel list to doughnuts: how many times each item is ordered
  "destination": Address, // Location that the order is being sent to.
}

Example Objects

const drone_1 : Drone = {
  "id" : 1, 
  "charge" : 98, 
}

const customer_1 : Customer = {
  "username" : "ricksanchez",
  "password": "longrandomhash",
  "previous_orders": [
    {
      "name": "Chocolate",
      "price": 1.99,
      "description": "A nice big chocolate doughnut.",
    },
  ],
    "employee": false,
}

const employee_1 : User = {
  "username" : "rocksandcheeze",
  "password" : "jksdyf576uryxdmmx87q2", 
  "employee": true,
}

const doughnut_1 : Doughnut = {
  "name" : "Chocolate",
  "price" : 1.99,
  "description" : "A nice big chocolate torus."
}

const location_1: Address = {
    'street': "1337 Leet Palace",
    'city': "Hackerplace",
    'state': "Despair",
    'zip': "1337",
}

const order_1: Order = {
  "user" : customer_1,
  "price" : 2.08,
  "doughnuts" : [doughnut_1, doughnut_2],
  "quantities" : [1, 2],
  "destination": location_1,
}
Clone this wiki locally