Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS442: ADVANCED PROGRAMMING USING JAVA Lab 6: Classes and objects Computer Science Department.

Similar presentations


Presentation on theme: "CS442: ADVANCED PROGRAMMING USING JAVA Lab 6: Classes and objects Computer Science Department."— Presentation transcript:

1 CS442: ADVANCED PROGRAMMING USING JAVA Lab 6: Classes and objects Computer Science Department

2 Lab Contents  Creating Classes and objects.  Private members.  Defining constructors.  Set and get methods. 2

3 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.

4 UML Diagram.. 4

5 Variables and constructors.. 5 Defined variables and constructors:

6 Set and get methods … 6 Defined set and get:

7 Area & perimeter methods … 7 Computing area and perimeter of square:

8 ToString.. 8 The method toString():

9 Main Class 9

10 Sample Run.. 10


Download ppt "CS442: ADVANCED PROGRAMMING USING JAVA Lab 6: Classes and objects Computer Science Department."

Similar presentations


Ads by Google