Skip to content

Instantly share code, notes, and snippets.

@Unalo
Last active January 18, 2022 12:51
Show Gist options
  • Save Unalo/7d96def87c6a69967e53eda5e2bac90f to your computer and use it in GitHub Desktop.
Save Unalo/7d96def87c6a69967e53eda5e2bac90f to your computer and use it in GitHub Desktop.

You are required to create a web app, to help local Municipality to track electricity usage per household. Each month the Municipality gives Household's 50 units each. As you use appliances, units will drop accordingly. If the units per household is equal or below 30, add a class warning into your current units.

In your app you must have the following.

  • Be able to top up teriffs.
  • Electricity usage, buy choosing a appliance.
  • Calculate total usage per household.
  • Calculate total usage per street (5 Houses makes a street)
  • Calculate the lowest usage per house in a street.
  • Calculate the highest usage per street.

Used appliances

Use drop-down or Checkboxes to display your appliances

name rate
Stove 4.5 units
Tv 2.0 units
Heater 1.5 units
Fridge 4.0 units
Kettle 1.8 units

Database setup

Household

id address meter_number street_id (fk) balance

Street

id name

Appliances

id name rate

Factory Functions

Function name Description
getCurrentUnits return the current units for a household
buyElectricity buy electricity for a household - use id as meter number
findHighestElectricityUsed Find the highest electricity used
findLowestElectricityUsed Find the lowest electricity used
findAvarageElectricityUsed Find average electricity used
useTeriff allow a house to use electricity - use appliances
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment