Java Lab

Question

I need the full solution to this partially completed lab. Full instructions included in the attached word file.

Attributes

  • description – text description of the competition
  • results – array of MazeResult objects
  • nextPos – whole number indicating the next available element position (index) in the array to add an object, also serves as the populated array count

 

Operations (methods):

  • A constructor that takes in a description
  • A get and set description method
  • A get method for the next position attribute (array populated element count)
  • Method to add a MazeResult object to the array
  • Methods to get a MazeResult object; one that takes in an array position index and one that takes in a rat ID string.
  • A method with conditional logic to give a count of all rats for a certain category (male, female, vaccinated, not vaccinated, all) triggered by a flag passed in as a whole number (1, 2, 3, 4, 5, respectively, implemented as public constants).  A similar method provides the average maze result (actual time) for each potential category.
  • A toString method that gives the test description and a count of maze results in the collection as well as looping through the array and calling the toString method for each MazeResult object.


  1. A starter BlueJ project will be provided to you.  You are to complete the coding of the Competition and CompetitionTest classes.
  2. You must use the provided project file and develop the lab within the BlueJ IDE to complete this assignment.
  3. Do NOT change the name, return type, or parameter order/type of any of the class methods.  These same attributes are used by Web-CAT to grade your submission, and you will end up losing points if they are changed.
  4. Each class constructor and method should have a corresponding unit test method.  Besides serving to verify that your code is accomplishing what you intended, writing unit test methods helps you understand how the objects should behave (how the class methods create, access, and mutate the object).  That is, writing the test methods first helps guide your class coding efforts.    


    1. Find and correct any syntax errors so that the classes in the project compile cleanly.
    2. Review the first JUnit test method, completing the code if necessary.  Note that proper testing includes making manual calculations to verify that expected values for a method action are equivalent to actual results.
    3. Once you feel the unit test method is a valid and robust test of the domain method’s expected behavior, review the corresponding domain class constructor or method and complete the coding if necessary.
    4. Run the JUnit test for the method.  If it does not pass, review and correct the code for this method.
    5. When the test passes, continue in like manner for the next and subsequent methods, iteratively completing tests and developing your class or classes.   All class methods must be tested.  



Details
Attachments
Purchase An Answer Below

Have a similar question?