CS442: ADVANCED PROGRAMMING USING JAVA Lab 6: Classes and objects Computer Science Department
Lab Contents Creating Classes and objects. Private members. Defining constructors. Set and get methods. 2
Case Study… 3 Write a program composed of two classes: 1. class Square. 2. class Use_Square, which contains method main that test the different methods in the class Square.
UML Diagram.. 4
Variables and constructors.. 5 Defined variables and constructors:
Set and get methods … 6 Defined set and get:
Area & perimeter methods … 7 Computing area and perimeter of square:
ToString.. 8 The method toString():
Main Class 9
Sample Run.. 10