Create a Workout Manager

Create a Workout Manager

Overview

The project involves creating a console-based push-up workout manager in Kotlin. The goal of this manager is to guide users through a series of three push-up sets, record their performance, and adjust future workout suggestions based on their results. The program will store the suggested repetitions for the user’s next workout in a file as an additional functionality.

Starting code

fun main() {
val interactor = WorkoutInteractor(
manager = WorkoutManager(),
nextRepetitionsRepository = FileNextRepetitionsRepository(),
)
interactor.startWorkout()
}

Project components

Within this project, the following key components are integral to the successful implementation and functionality:

  • The Repetitions data class

  • The NextRepetitionsRepository interface

  • The FileNextRepetitionsRepository class

  • The WorkoutManager class

  • The WorkoutInteractor class

User interaction examples

Here is what an example conversation with a user might look like:

:::::::: First interaction :::::::::
Hello, I am your push-ups workout assistant!
Now do 5 push-ups
How many push-ups did you do?
5
Now rest for 1 minute
Now do 5 push-ups
How many push-ups did you do?
4
Now rest for 1 minute
Now do as many push-ups as you can!
How many push-ups did you do?
3
Your next repetitions will be: 5 and 4
:::::::: Second interaction :::::::::
Hello, I am your push-ups workout assistant!
Now do 5 push-ups
How many push-ups did you do?
5
Now rest for 1 minute
Now do 4 push-ups
How many push-ups did you do?
5
Now rest for 1 minute
Now do as many push-ups as you can!
How many push-ups did you do?
6
Your next repetitions will be: 6 and 5
:::::::: Third interaction :::::::::
Hello, I am your push-ups workout assistant!
Now do 6 push-ups
How many push-ups did you do?
-1
Please enter a valid number.
How many push-ups did you do?
0
Now rest for 1 minute
Now do 5 push-ups
How many push-ups did you do?
10
Now rest for 1 minute
Now do as many push-ups as you can!
How many push-ups did you do?
0
Your next repetitions will be: 5 and 4

Note: After each interaction, the code stores and retrieves values from the next_repetitions.txt file, allowing the workout assistant to remember the progress across sessions.

Exception handling

Implement proper exception handling in the FileNextRepetitionsRepository class to manage file-related exceptions.

Code review

Review your code for readability, adherence to best practices, and efficient use of Kotlin features.

Instructions

In the given starting code, you have the initial setup for a console-based push-up workout manager in Kotlin. Your task is to complete the implementation by adding the necessary code for the workout manager, repetitions repository, and user interaction as per the provided specifications.

Points to remember:

  • Finish each task according to the instructions.

  • Refer to the provided solution if needed.

  • After successfully completing all tasks, it is crucial to run the project at the end to verify its functionality with the provided starting code in the main function.

Good luck with your implementation!