Question: 4 1 CSCI 1 3 0 2 Programming Principles II Georgia Southern University Department of Computer Science Fall 2 0 2 4 Lab 3 Point

4
1
CSCI 1302 Programming Principles II
Georgia Southern University
Department of Computer Science
Fall 2024
Lab 3
Point Value: 20 points
Due: Friday August 30,2024, end of lab
Objectives
1. Update an existing class to explore aggregation and composition.
2. Review UML language and documentation.
3. Use debugging techniques to debug and correct code.
4. Use the IDEs built-in debugger to debug and correct code.
5. Archive Java source code files and other documents into a zip file.
Description
Complete the following steps as described and upload requested materials to Folio in the
appropriate Dropbox in a single zip file. Submit Java source code files to Gradescope.
Students should work in groups of two for this lab. When submitting your zip file, fill out
the comment header and indicate both group member names. On Gradescope, you can
choose to add a group member, once one person has submitted the code file, must be
done to every submission.
Your submitted zip file should be named Lab#LastName1LastName2.zip. For instance,
Lab3JonesSmith. Any requested screenshots and/or answers to questions should be
included in a separate Word document.
All programs should have a comment header. That comment header should
include information similar to:
/**
* File: PAssign0.java
* Class: CSCI 1302
* Author: Christopher Williams
* Created on: Jun 6,2016
* Last Modified: Aug 16,2018
* Description: Display three messages to the console
*/
Before writing any code, for each problem, discuss with your partner how you plan to
approach solving the given problem. Once you both agree on a way to attempt the
problem, only then should code be written.
Pay attention to names and any other requested material. Failure to include material
will result in the loss of points as described below.
2
Lab Problems
For all problems, use inline comments to describe major actions. Ask for assistance if needed.
NOTE: For this lab, you will be using the WaterBottle class and test program provided in Folio.
You will need to modify the test program to test the new classes you will be building.
Look for the TODO comments and delete each comment when you complete it. These show up
in Eclipse in the Tasks tab: Windows -> Show View -> Tasks.
1. Composed/Aggregated Objects Create a new class named LunchBag. LunchBag should
have data members of length, width, height, and a water bottle. All LunchBags have a bottle
holder that can hold a WaterBottle that can be purchased separately from the LunchBag (so
it can be created in a main method and passed to the LunchBag class).
Additional Requirements
a) A default LunchBag should have dimensions of 11.2L x 6.1W x 7.9H.
b) There should be a default constructor that sets default values for the LunchBag. Create
a default WaterBottle in this constructor: setWaterBottle(new WaterBottle());.
c) There should be a convenience constructor that takes four parameters that match all
data members in the order they are listed in the description above.
d) All LunchBag data members should have an accessor and a mutator and all values
should be positive. If they are not positive, set them to their default values.
This includes the WaterBottle data member which should also have an accessor
and a mutator.
e) A LunchBag can hold a WaterBottle as long as the diameter is positive and less than or
equal to 4.
If a WaterBottle is set using the appropriate mutator method, an error message
should be printed if the WaterBottle cannot be stored and a default WaterBottle
should be used in its place.
Note that an error message in the mutator is not the most appropriate
way to accomplish this. In Chapter 12, we will learn the correct way.
Submit both your WaterBottle and LunchBag classes to Gradescope.
2. Composed/Aggregated Objects Create a new class named LunchBox. LunchBox should
have data members of length, width, and a water bottle. All LunchBoxs come with an
included WaterBottle that is manufactured at the same time as the LunchBox and cannot be
replaced with off-the-shelf WaterBottles (we have no way of preventing this at the moment
because users will have access to the accessor method (similar to the immutable example in
the slides)).
Additional Requirements
a) A default LunchBox should have dimensions of 10.6L x 7.7W x 6.33H.
b) The default WaterBottle that comes with the LunchBox is 4.0H and 0.9R.
3
o As a composed object, this should be created at the same time as the LunchBox.
c) There should be a default constructor that sets default values for the LunchBox and
instantiates the WaterBottle with the correct dimensions as a composed object.
d) There should be a convenience constructor that takes four parameters that match all
data members in the order they are listed above.
e) All LunchBox data members should have an accessor and a mutator and all values
should be positive. If they are not positive, set them to their defau

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!