Lab 05.1: Creating Classes: Objective
Lab 05.1: Creating Classes: Objective
1: Creating Classes
Objective
This lab will provide practice in creating classes, methods and attributes. You will
also implement several small methods in your new class during this exercise.
Overview
3. Create private attributes in your Box class for each of these pieces of
information. Use double as the data type for each attribute.
4. Create public methods to set each attribute and retrieve (get) each attribute.
Right click on the editor window and select the Source menu. From that menu
select “Generate Getters and Setters”. Check the “Select all” and “Generate
Comments” boxes. From the location dropdown choose last member and
then click finish.
Exercise 2: Create Constructors
a. The first should accept 3 parameters and assign them to the length,
width and height attributes respectively. Note: there is a wizard on
the “Source” menu that will create this without typing.
b. If all 3 sides are set correctly (i.e. greater than 0), it will print a
message in the following form:
Note: we will not test any of our code at this point. Once we cover creating
objects and calling class methods, we will ensure that all the code is operating
correctly.
Challenge Exercises: