logo

Crowdly

Browser

Додати до Chrome

Your task is to add the missing code in an EllipticalMachine class and its corre...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

Your task is to add the missing code in an EllipticalMachine class and its corresponding JUnit test class EllipticalMachineTest , based on the PEKKO IoT tutorial example we saw in class.

You will implement the following messages in the EllipticalMachine class.

  • RecordWeightInKgAndResistanceLevel. Record the weight of the user, and the resistance level chosen, i.e., 100 kg, level 2.
  • CalculateCaloriesBurned.   Calculate calories burned per minute using the following formula: Calories burned per minute = (MET * body weight in Kg * 3.5) ÷ 200.  Where “MET'' is a measurement of the energy cost of physical activity for a period of time. You can find an activity’s MET on the table below.

Type of activity

MET

Resistance level 2, light effort

4.6

Resistance level 5, moderate effort

4.9

Resistance level 8. vigorous effort

5.7

For example, Calories burned per minute = (4.6 * 100 * 3.5) ÷ 200

=8.049999999999999 (using Java Double precision).

Your test scenario:

  • Record the following weight and temperature: 100 Kg., resistance level 2 and calculating the calories burned.  Add the missing code in EllipticalMachineTest class, specifically inside the method called "testReplyWithCaloriesBurnedPerMinute"

Expected result:

[2025-11-14 14:07:17,409] [INFO] [org.apache.pekko.event.slf4j.Slf4jLogger] [EllipticalMachineTest-pekko.actor.default-dispatcher-3] [] - Slf4jLogger started

[2025-11-14 14:07:17,464] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-5] [pekko://EllipticalMachineTest/user/$a] - Eliptical Machine actor group-device started

[2025-11-14 14:07:17,471] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-5] [pekko://EllipticalMachineTest/user/$a] - Calories burned per minute unknown. Weight was not set.

[2025-11-14 14:07:17,477] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-3] [pekko://EllipticalMachineTest/user/$b] - Eliptical Machine actor group-device started

[2025-11-14 14:07:17,478] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-3] [pekko://EllipticalMachineTest/user/$b] - Recorded weight in Kg 100.0 with 1

[2025-11-14 14:07:17,479] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-3] [pekko://EllipticalMachineTest/user/$b] - Recorded resistance level2 with 1

[2025-11-14 14:07:17,479] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-5] [pekko://EllipticalMachineTest/user/$b] - Calories burned per minute = 8.049999999999999 

[2025-11-14 14:07:17,480] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-3] [pekko://EllipticalMachineTest/user/$b] - Recorded weight in Kg 100.0 with 3

[2025-11-14 14:07:17,480] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-3] [pekko://EllipticalMachineTest/user/$b] - Recorded resistance level5 with 3

[2025-11-14 14:07:17,480] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-5] [pekko://EllipticalMachineTest/user/$b] - Calories burned per minute = 8.575000000000001 

[2025-11-14 14:07:17,508] [INFO] [org.apache.pekko.actor.CoordinatedShutdown] [EllipticalMachineTest-pekko.actor.default-dispatcher-3] [CoordinatedShutdown(pekko://EllipticalMachineTest)] - Running CoordinatedShutdown with reason [ActorSystemTerminateReason]

[2025-11-14 14:07:17,526] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-6] [pekko://EllipticalMachineTest/user/$a] - Eliptical Machine actor group-device stopped

[2025-11-14 14:07:17,526] [INFO] [com.example.EllipticalMachine] [EllipticalMachineTest-pekko.actor.default-dispatcher-3] [pekko://EllipticalMachineTest/user/$b] - Eliptical Machine actor group-device stopped

Process finished with exit code 0

Important:

  • You must work on the code provided in the link https://drive.google.com/file/d/1k0JhIkf4FY7-EznbSss0sJZXCcWgBanw/view?usp=drive_link

  • Do not change anything in the provided files.  Add your solution below the //TODO: comments inside EllipticalMachine and EllipticalMachineTest.

  • Only submit EllipticalMachine.java and EllipticalMachineTest.java

  • You must include your full name in each class as a comment.

  • Your score for this question will be based on

    • The correctness of your test class (2 points)

    • The correct use of PEKKO (4 points)

    • The correct computation of the calories burned (3 points)

Total 9 points.

Remember that you can compile and run the test using the command  “sbt test” in the command line inside the project root folder.

 

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на moodle.concordia.ca?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome