You are on page 1of 42

Course Supervisor: Dr.

Humera Tariq
Hands On Lab Sessions: Mr. Usman Amjad
Department of Computer Science
University of Karachi.
Contents

Net Beans Installation


UML of Class Box
How to create object from Class Box
How to call function on object of class Box
How to Code your favorite object Samosa
enum, switch and private discussion
Assignment
The IDE for Java Developers
An alternative to it is Eclipse.
Destination folder can be changed by clicking
on Change button Click Next to proceed
Click Close to complete installation
After installation of JDK, install NetBeans IDE
by double clicking the setup icon
Accept and then click Next to proceed
Click Finish to complete installation
Open NetBeans by double clicking the icon on
desktop
Class Box
Go to File -> New Project
Right Click on package name OopLab1, then
click New, then Java class
Click on green arrow button or press F6 key
to compile and execute your program
Class Samosa
Main Class/ Driver Class
Automatically generated Code

Main Class/ Driver Class


You need to create a Back End Class Samosa
Observe Red Markers Care fully

Class 1 : Main.java here named as


SamosaParty.java

Class 2 : Samosa.java which represents


your object
Create Object with new operator and Run the Project

Sochne ki baat ye hai


ke Class Samosa is
empty this time
Sochne ki baat ye hai ke
Class Samosa is empty
this time
This is the magic of
default constructor.
You are standing in
Main.java

Trying to Change
state of Samosa

Read Compiler
Comments
Go to Samosa.java and
write
changeState()function
Comeback to main.java
and you will see that error
is resolved

You make the compiler happy again.


He has no objection at all now.
Class Samosa
Go to Samosa.java Make the fields
private. Now you need setter and getters
functions.
Compiler is sad again
Go to Samosa.java and write getter()
and setter functions
In your Lab File draw neat and proper UML for
Bulb, Spider, Circle, Cylinder

Map your UML onto Java Code. Make it check


in lab and add hand written code in Lab file.

You might also like