Use class abstraction and encapsulation concepts to re-draw the UML class diagram of Square class that you drew in Lab 02. Discuss: Do you think the data field (side) should be declared private (hidden)? Why? If the data field is declared private (hidden), how the data field can be accessed from outside the class (for example, from the Test class)? The new UML class diagram should include the getter and setter methods which deal with the data field side. Create a new Java Application project called lab_03. Copy the source files of the classes java and TestSquare.java that you created in Lab 01 and paste both source files in the default package. (you may need to fix any problems related to package declaration) Open Square and TestSquare classes using NetBeans editor. Use class abstraction and encapsulation concepts to modify the implementation of Square class, so the new class implementation would satisfy the class abstraction and encapsulation concepts. Add any required getter and setter methods to the class Square. Fix any compiling errors in the TestSquare class as a result of modifying the class Square. Run the Test TestSquare

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
  1. Use class abstraction and encapsulation concepts to re-draw the UML class diagram of Square class that you drew in Lab 02.

Discuss:

Do you think the data field (side) should be declared private (hidden)? Why?

If the data field is declared private (hidden), how the data field can be accessed from outside the class (for example, from the Test class)?

The new UML class diagram should include the getter and setter methods which deal with the data field side.

  1. Create a new Java Application project called lab_03.
  2. Copy the source files of the classes java and TestSquare.java that you created in Lab 01 and paste both source files in the default package. (you may need to fix any problems related to package declaration)
  3. Open Square and TestSquare classes using NetBeans editor.
  4. Use class abstraction and encapsulation concepts to modify the implementation of Square class, so the new class implementation would satisfy the class abstraction and encapsulation concepts.
  5. Add any required getter and setter methods to the class Square.
  6. Fix any compiling errors in the TestSquare class as a result of modifying the class Square.
  7. Run the Test TestSquare

  

             

 

Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education