Question

In: Computer Science

import java.util.ArrayList; public class Workouts { public enum Muscle {ABS, BACK, BICEPS, CHEST, FOREARM, GLUTES, LOWERLEG,...

import java.util.ArrayList;

public class Workouts {


public enum Muscle {ABS, BACK, BICEPS, CHEST, FOREARM, GLUTES, LOWERLEG, SHOULDER, TRICEPS, UPPERLEG, NONE} // Why didn't I have to declare this static?
public enum Equipment {BARBELL, BODYWEIGHT, DUMBBELL, CABLE, HAMMERSTRENGTH}
   private final ArrayList<Workout> workoutList = new ArrayList<Workout>();
   // You will need to create a number of methods for the inner class. You are not limited to
   // only the methods listed inside this class.
   private class Workout {
   private String name;
   private Equipment equipment;
       private Muscle primaryMuscle;
       private Muscle secondaryMuscle;
       private String desc;
       private String reminders;
  
Workout(String name, Equipment equipment, Muscle primaryMuscle, Muscle secondaryMuscle, String desc, String reminders)

{

// How do we get the name of an enumeration value?
//should instantiate an instance of the workout class
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I would like help on the constructor

Solutions

Expert Solution

class Workouts {

        public enum Muscle {
                ABS, BACK, BICEPS, CHEST, FOREARM, GLUTES, LOWERLEG, SHOULDER, TRICEPS, UPPERLEG, NONE
        } // Why didn't I have to declare this static?
        // Because The Enums are used by your class methods and innner class.
        // a inner class like Workout, always work in tandem with the outer class.. so 
        // it can access members of outer class, and hence the enums

        public enum Equipment {
                BARBELL, BODYWEIGHT, DUMBBELL, CABLE, HAMMERSTRENGTH
        }

        private final ArrayList<Workout> workoutList = new ArrayList<Workout>();

        // You will need to create a number of methods for the inner class. You are not
        // limited to
        // only the methods listed inside this class.
        private class Workout {
                private String name;
                private Equipment equipment;
                private Muscle primaryMuscle;
                private Muscle secondaryMuscle;
                private String desc;
                private String reminders;

                public Workout(String name, Equipment equipment, Muscle primaryMuscle, Muscle secondaryMuscle, String desc,
                                String reminders) {
                        this.name = name;
                        this.equipment = equipment;
                        this.primaryMuscle = primaryMuscle;
                        this.secondaryMuscle = secondaryMuscle;
                        this.desc = desc;
                        this.reminders = reminders;
                        
                        // How do we get the name of an enumeration value?
                        //should instantiate an instance of the workout class
                        
                        // If you want just the string value of a enum, you can do below:
                        // primaryMuscle.toString()
                }
        }
}

Related Solutions

import java.util.ArrayList; import java.util.Collections; public class BirthdayList { /** * This is the main process for...
import java.util.ArrayList; import java.util.Collections; public class BirthdayList { /** * This is the main process for class BirthdayList */ public static void main() { System.out.println("\n\tBegin Birthday List Program\n");    System.out.println("Declare an ArrayList for Birthday objects"); // 1. TO DO: Declare an ArrayList to store Birthday objects (3 Pts)       // 2. TO DO: Replace the xxx.xxxx() with the appropriate method (2 Pts) System.out.printf("\nBirthday List is empty: %s\n", xxx.xxxx() ? "True" : "False");    System.out.println("Add at least five Birthdays to...
import java.util.ArrayList; import java.util.Collections; import java.lang.Exception; public class ItemList { /** This is the main process...
import java.util.ArrayList; import java.util.Collections; import java.lang.Exception; public class ItemList { /** This is the main process for the project */ public static void main () { System.out.println("\n\tBegin Item List Demo\n"); System.out.println("Declare an ArrayList to hold Item objects"); ArrayList<Item> list = new ArrayList<Item>(); try { System.out.println("\n Add several Items to the list"); list.add(new Item(123, "Statue")); list.add(new Item(332, "Painting")); list.add(new Item(241, "Figurine")); list.add(new Item(126, "Chair")); list.add(new Item(411, "Model")); list.add(new Item(55, "Watch")); System.out.println("\nDisplay original Items list:"); listItems(list); int result = -1; // 1....
import java.util.ArrayList; import java.util.Collections; import java.lang.Exception; public class ItemList { /** This is the main process...
import java.util.ArrayList; import java.util.Collections; import java.lang.Exception; public class ItemList { /** This is the main process for the project */ public static void main () { System.out.println("\n\tBegin Item List Demo\n"); System.out.println("Declare an ArrayList to hold Item objects"); ArrayList list = new ArrayList(); try { System.out.println("\n Add several Items to the list"); list.add(new Item(123, "Statue")); list.add(new Item(332, "Painting")); list.add(new Item(241, "Figurine")); list.add(new Item(126, "Chair")); list.add(new Item(411, "Model")); list.add(new Item(55, "Watch")); System.out.println("\nDisplay original Items list:"); listItems(list); int result = -1; // 1....
Convert this pseudo code program into sentences. import java.util.ArrayList; import java.util.Collections; class Bulgarian {    public...
Convert this pseudo code program into sentences. import java.util.ArrayList; import java.util.Collections; class Bulgarian {    public static void main(String[] args)    {        max_cards=45;        arr->new ArraryList        col=1;        card=0;        left=max_cards;        do{            col->random number            row->new ArrayList;            for i=0 to i<col            {                card++                add card into row            }   ...
This is the class that needs to be written... import java.util.ArrayList; /** * Deals out a...
This is the class that needs to be written... import java.util.ArrayList; /** * Deals out a game of 5-card-stud. * * @author PUT YOUR NAME HERE * @version PUT THE DATE HERE */ public class FiveCardStud { private Deck myDeck; private ArrayList<Hand> players; /** * Constructor for objects of class FiveCardStud */ /* Write a constructor for the FiveCardStud class. The constructor accepts a single integer parameter for the number of players. The number of players should be from 2...
Abstract Cart class import java.util.ArrayList; import java.util.HashMap; /** * The Abstract Cart class represents a user's...
Abstract Cart class import java.util.ArrayList; import java.util.HashMap; /** * The Abstract Cart class represents a user's cart. Items of Type T can be added * or removed from the cart. A hashmap is used to keep track of the number of items * that have been added to the cart example 2 apples or 4 shirts. * @author Your friendly CS Profs * @param -Type of items that will be placed in the Cart. */ public abstract class AbstractCart {...
Please add comments to this code! JAVA code: import java.util.ArrayList; public class ShoppingCart { private final...
Please add comments to this code! JAVA code: import java.util.ArrayList; public class ShoppingCart { private final ArrayList<ItemOrder> itemOrder;    private double total = 0;    private double discount = 0;    ShoppingCart() {        itemOrder = new ArrayList<>();        total = 0;    }    public void setDiscount(boolean selected) {        if (selected) {            discount = total * .1;        }    }    public double getTotal() {        total = 0;        itemOrder.forEach((order) -> {            total +=...
Can you please add comments to this code? JAVA Code: import java.util.ArrayList; public class Catalog {...
Can you please add comments to this code? JAVA Code: import java.util.ArrayList; public class Catalog { String catalog_name; ArrayList<Item> list; Catalog(String cs_Gift_Catalog) { list=new ArrayList<>(); catalog_name=cs_Gift_Catalog; } String getName() { int size() { return list.size(); } Item get(int i) { return list.get(i); } void add(Item item) { list.add(item); } } Thanks!
Stack Class //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Queue Class public class Stack { private java.util.ArrayList pool = new java.util.ArrayList(); pu
Stack Class //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Queue Class public class Stack { private java.util.ArrayList pool = new java.util.ArrayList(); public Stack() { }    public Stack(int n) { pool.ensureCapacity(n); }    public void clear() { pool.clear(); }    public boolean isEmpty() { return pool.isEmpty(); }    public Object topEl() { if (isEmpty()) throw new java.util.EmptyStackException(); return pool.get(pool.size()-1); }    public Object pop() { if (isEmpty()) throw new java.util.EmptyStackException(); return pool.remove(pool.size()-1); }    public void push(Object el) { pool.add(el); }    public String toString() {...
The biceps muscle connects to the bones of the forearm about 2.15 cm beyond the joint. Assume the forearm has a mass of 2.25 kg and a length of 0.425 m.
 The bones of the forearm (radius and ulna) are hinged to the humerus at the elbow. The biceps muscle connects to the bones of the forearm about 2.15 cm beyond the joint. Assume the forearm has a mass of 2.25 kg and a length of 0.425 m. When the humerus and the biceps are nearly vertical and the forearm is horizontal, if a person wishes to hold an object of mass 4.55 kg so that her forearm remains motionless, what...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT