Week 11 - OOP concepts & LLMs

Object oriented programming

Classes and objects

Encapsulation

Code style: clean code

LLMs

Tokenization

Inference

Tools

RAGs

Using LLMs in code

Practice

Assignment

Core program

Week 11 Assignment

Task 1: Time class

Create a class called Time that represents a time of day. The class tracks the a time using a single property: the number of seconds since midnight. It then calculates the hours, minutes, and seconds from this property.

For example:

Seconds from midnight Current time
0 00:00:00
3602 01:00:02
45296 12:34:56
86399 23:59:59
< 0 Invalid
≥ 86400 Invalid

Requirements

Private properties

Public Methods

Logic for addSeconds, addMinutes, and addHours

Example usage

const myTime = new Time(12, 35, 0);
console.log(myTime.toString()); // 12:35:00
myTime.getHours(); // 12
myTime.getMinutes(); // 35
myTime.getSeconds(); // 0

myTime.addMinutes(25);
console.log(myTime.toString());  // 13:00:00

myTime.addHours(12);
console.log(myTime.toString());  // 01:00:00

Unit tests

A unit test suite has been written to help out with the implementation. Run it with npm test . Feel free to take a look at the implementation of the tests or add your own.


Task 2: AI powered quiz game

Build a quiz app where an LLM generates the questions. The player sees one question at a time with four possible answers. They type the correct answer (1, 2, 3, or 4), and the application shows whether they answered correctly.

The quiz will end after 10 questions and show the final score at the end.

Requirements

<aside> ❗

Never push your GitHub token to GitHub. Use .gitignore or environment variables.

If you accidentally push a token to GitHub, revoke it immediately and generate a new one.

</aside>

Tips & Guidance

Bonus


Submission

Follow the Assignment submission guide to learn how to submit the assignment


The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 *https://hackyourfuture.net/*

CC BY-NC-SA 4.0 Icons

Built with ❤️ by the HackYourFuture community · Thank you, contributors

Found a mistake or have a suggestion? Let us know in the feedback form.