Question
Learning Objectives: Write classes that relate to simple geometric shapes. Create objects from classes that you wrote. 1. Write a class called Square by following
Learning Objectives: Write classes that relate to simple geometric shapes. Create objects from classes that you wrote. 1. Write a class called Square by following steps. a. Write the class header. b. Declare a private instance variable called length. c. Write a constructor that initializes the instance variable in the class. d. Write an accessor method for the instance variable. e. Write a mutator method for the instance variable.
2. Write a class called Test with a main method that: a. creates a Square object and initializes its length to 1.2. b. uses the mutator method to change the length stored in the Square object to 8.8. c. then uses the accessor method to display the length stored in the Square object.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started