, ,

[SOLVED] Lab 10 Fall 2022

$25

File Name: Lab_10_Fall_2022.zip
File Size: 150.72 KB

Categories: , , Tags: , ,
5/5 - (1 vote)

Java Lab 10

Fall 2022

In this lab, you will practice with encapsulation or the lack thereof.

Create a project named Lab10. Right click on the src icon and create a new Package named DataPackage.

Download Lab10Main.java and copy it into src; download Data.java, DataSnooper.java, and ContainedClass and copy them all into DataPackage. Compile and run the program.  Take a look at class DataSnooper.

As you do each problem below, ask yourself, what’s wrong? Where is encapsulation being broken?

1. Add fixes to Data and DataSnooper for the part labeled Problem 1 to enforce encapsulation.

2. Add fixes to those classes for Problem 2.

3. Add fixes for Problem 3.

4. Add fixes for Problem 4.

5. Add fixes for Problem 5. Note that this also involves ContainedClass.

6. Change Data.setCc( ) to do a deep copy: create a new ContainedClass, copy the parameter’s data into it, then set Data’s field.

7. Add code to Data to enforce the following rules. Then add tests at the end of DataSnooper that attempt to violate each rule using object d; print out d to show that the rule holds.

a. iValue must be positive; if not, do not reset it. b. sValue can have a maximum of 10 characters. c. iList can have a maximum of 4 entries.

d. iList’s entries must be between 10 and 20 inclusive.

Deliverable: Zip up all your .java files and upload the zip file to Canvas.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Lab 10 Fall 2022[SOLVED] Lab 10 Fall 2022
$25