Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benjamin-firth/eedf4f59824ba642ddf143f63b7ed357 to your computer and use it in GitHub Desktop.
Save benjamin-firth/eedf4f59824ba642ddf143f63b7ed357 to your computer and use it in GitHub Desktop.
Create Classes
UserRepository Class:
Description: Contains all users data.
Properties:
- userData (array of users)
- userId
- stepGoal
Methods:
- find user by ID / return user object based on the ID.
- calculate average step goal / return average step goal for all users.
- getAllUserAverageQualtiy / takes information about all user's quality numbers and calculates average
- findGoodSleepWeekUsers / takes date, find 7 days before for every user, for each user calculate average, find users with average over 3.
- findSleepingBeauty / take date, sorts array of all sleep times, returns user with most for given day.
- findAverageStairsClimbed / takes data and date, return average number of stairs climbed
- findAverageStepsTaken / takes data and date, return average number of steps taken
- findAverageMinutesActive / takes data and date, return average number of minutes active
- findForestGumpOfDay / takes date, return user with most steps taken
User:
Description: Represent a single user.
Parameter: userData (object)
Properties:
- id / integer
- name / string
- address / string
- email / string
- strideLength / integer or float
- dailyStepGoal / integer
- friends / array of id numbers
- userInfo / object with all information involving activity, sleep, hydration
Methods:
- getFirstName / return only first name
- tellAboutSleep / take date, hours, quality
Hydration:
Description: Contains information about water balance
Parameters: data (object)
Properties:
- userId
- date
- numOunces
Methods:
- calculateAverageFluid / take all similar Id's as array, calculates average per day for one user for all time.
- findDayFluid / takes Id and date, return fluids drank
- findWeeksFluid / gets array of last 7 days starting with a date, and then subtracting 7, and returns drink amounts for each day element as a collective array.
Sleep:
Description: Contains information about sleep
Properties:
- userId
- date
- hoursSlept
- sleepQuality
Methods:
- calculateDayAverageSleepLength / take data, return average for all days
- calculateAllAverageSleepQuality / take data, return average for all days for one user
- getSleptHours / takes id and date, return hours slept
- getSleepQuality / takes id and date, return sleep quality
- getWeeklySleepHours / takes id and date, return array of 7 days before given date with sleep hours for each day
- getWeeklySleepQuality / takes id and date, return array of 7 days before given date with sleep quality for each day
Activity: Contains information about activity
Description:
Properties:
- userID
- date
- numSteps
- minutesActive
- flightsOfStairs
Methods:
- getDayMiles / takes date and id, return product of stride length and number of steps
- getDayActiveMins / takes date and id, return active minutes
- getWeekActiveMinsAverage / takes id and date, return average of last 7 days for acrtive minutes
- checkStepGoal / takes id and date, return true or false based on steps in the day vs step goal
- findGoalCompletedDays / takes id, return array of all days with goal completed
- findStairRecord / takes id, get array of all stair climb data, return day with the most flights
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment