write code in java and comment. thanks. the program is about interface . Implement the basics of...

50.1K

Verified Solution

Question

Programming

write code in java and comment. thanks. the program isabout interface .

  1. Implement the basics of Fitness and types of Fitness:Aerobic.
  2. Implement specific Fitness types such as Swimming,Cycling,

Fitness Task:
public interface Fitness

(10pts) This will be used as a starting point forderiving any specific Fitness type. Every fitness exercise type hasone or more muscle group it affects. Therefor a Fitness has thefollowing abstarct method (Note that all methods in an interfaceare abstract by default):

  • public Muscle [ ] muscleTargeted() A method that returns themuscle that is going to be affected by the fitness. Note that thereturn type of the method is Muscle. A human body has a finitenumber of muscle parts that can be affected by fitness exercises.Define an enum datatype called Muscle with the follwoing membervaluesAbs,Back,Biceps,Chest,Arms,Glutes,Shoulders,Triceps,Legs,Cardio
  • public double calorieLoss(Intensity intensity, double weight,int duration) - returns the total amount of calorie burnt by theexercise for the duration number of minutes for a person with thegiven weight. Intensity can be HIGH, MEDIUM, LOW. Note thatIntensity is a good candidate to be definied as enum.
  • public String description() a method that returns a shortdecription of the fitness type.

Aerobic Task:

(10pts) Aerobic means \"with oxygen.\" The purpose ofaerobic conditioning is to increase the amount of oxygen that isdelivered to your muscles, which allows them to work longer.Aerobic is a Fitness. However, we cannot give the actualimplementation for the methods muscleTargeted() and calorieLoss()as we don't know the actual aerobic exercise. The descripton()method returns the string Aerobic means \"with oxygen.\". Note thatAerobic is a good candidate to be abstract class.

public class Swimming, which is an Aerobic

This class represents an actual Aerobic exercise, i.e., itextends Aerobic class, that a user can do to burn calories. Thecalculation of how much calorie will be burn relies on a key valueknown as a MET, which stands for metabolic equivalent.One \"MET\" is\"roughly equivalent to the energy cost of sitting quietly,\" and canbe considered 1 kcal/kg/hour. The MET values of some of theexercises that we consider of this project are displayed in thefollowing table. The MET value multiplied by weight in kilogramstells you calories burned per hour (MET*weight inkg=calories/hour). There are different types swimming:Butterflystroke, Freestyle, and Breaststroke. These different typesof swimming activities affects different muscles. Butterflystroke:Abs,Back, Shoulders,Biceps,Triceps; Breastsstroke: Glutes, Cardio;Freestyle: Arms,Legs,Cardio.

Define a class Swimming. The class must includethe following:

  • public Swimming (SwimmingType type) - defines the constructorfor the class. You need to define an enum datatype calledSwimmingTypewith membersButterflyStroke,Breaststroke,Freestyle
  • public Swimming () - a default constructor for the class thatinitilizes SwimmingType to Freestyle.
  • public void setSwimmingType(SwimmingType type) A setter for theswimmingType.
  • public SwimmingType getSwimmingType() A getter for theswimmingType.
  • @Override public String description() returns the name of theclass.

public class Cycling, which is an Aerobic

(10pts) This class represents an actual Aerobicexercise, i.e., it extends Aerobic class, that a user can do toburn calories. Cycling affects muscles: Glutes, Cardio, Legs.Define a class Cycling. The class also has:

  • @Override public String description() returns the name of theclass.
ExerciseHIGHMEDIUMLOW
Swimming10.08.36.0
Cycling14.08.54.0
Yoga4.03.02.0
Weightlifting6.05.03.5
Plyometrics7.44.82.5
Tai Chi5.03.01.5
Squat7.05.02.5
Pull-Up7.56.04.8

Answer & Explanation Solved by verified expert
3.9 Ratings (541 Votes)
Fitnessjavapackage fitnesspublic interface Fitness A method that returns the muscle that is goingto be affected by the fitness public Muscle muscleTargeted returns the total amount of calorie burnt by theexercise for the duration number of minutes for a personwith the given weight public double calorieLossIntensity intensity doubleweight int duration returns a short description of the fitnesstype public String descriptionMusclejavapackage fitnesspublic enum Muscle Abs Back Biceps Chest Arms Glutes ShouldersTriceps Legs CardioIntensityjavapackage fitnesspublic enum Intensity HIGH MEDIUM LOWAerobicjavapackage fitnesspublic abstract class Aerobic implements Fitness abstract methods must be implemented in childclasses public    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students