Oop Lab Manual
Oop Lab Manual
Oop Lab Manual
PCC-CS593
Last Revised
Jul 2023
Compiled by
Utpal Das
Dept. of CSE
Techno Main Salt Lake
(formerly Known as Techno India Salt Lake)
GENERAL INSTRUCTION FOR LABORATORY CLASSES
DO’S
☑ Without prior permission of teacher students should not enter into the laboratory.
☑ Students should come with proper uniform.
☑ Students should maintain silence inside the laboratory.
☑ After completing the laboratory exercise, make sure to shut down the system
properly.
DONT’S
☒ Students using the computers in an improper way.
☒ Students scribbling on the desk and mishandling the chairs.
☒ Students using mobile phones inside the laboratory.
☒ Students making noise inside the laboratory.
HARDWARE REQUIREMENTS
PROCESSOR: Dual core or HIGHER
RAM: 4GB or HIGHER
HDD: 160GB
SOFTWARE REQUIREMENTS
OPERATING SYSTEM: Ubuntu 12.04 LTS or
HIGHER
JDK 1.8 or HIGHER
PREREQUISITE
Computer fundamentals, Logic building skills, Mathematics (basics
like prime number, factorial, fibonacci series etc.), etc.
(Source: http://makautexam.net/aicte_details/aicteugdetails.html)
Laboratory Experiments
The following list shows sample experiments. Actual experiments can be found under the learning portal
(etcm.ticollege.org/cms1):
Step 2: Create a work folder inside Home location. Save the opened gedit file with a proper naming
convention with an extension as .java for the filename inside work folder. Click on Save option to save the
.java file.
Step 3: Search for terminal in the search bar. Once terminal is shown in the results click on it.
Step 4: Th
e terminal window opens.
pwd command is used to check the current directory location in terminal.
cd (change directory) command is used to change directory location in terminal. In this case, cd work
changes the current directory path to work folder location(source file ie; .java file location).
ls command is used to list the contents of any folder/directory. In this case, we can use this command to
check whether the programmer is in the correct source file location, thus, assuring the source file is present
in the folder location.
Step 5: Compile the Java program (source code ie; firstProg.java) to generate the executable code. Upon
successful compilation an executable file is produced with the name firstProg. On failure we need to correct
the source code and recompile again till it compiles successfully. To execute the java program, follow the
below steps.
https://www.eclipse.org
Step 2: Install Eclipse IDE.
Use the commands below to extract the content in the ~/Downloads folder. The next line launches the
installer.
tar xfz ~/Downloads/eclipse-inst-linux64.tar.gz
~/Downloads/eclipse-installer/eclipse-inst
Use the onscreen instructions to complete the installer.. Accept the default installation directory and continue.
Next, accept the license terms and continue wait for Eclipse installer to download and install all the
packages.
After downloading the installer should complete. All you have to do is launch the program.
setting the breakpoint click on the Start debugger icon to start the debugger.
Step 2: When the first breakpoint is reached, the program will stop and the Variables tab will show the values
of all the variables available currently. You can check these values to see if something is wrong, or if
something doesn’t appear the way you planned it’d.
The currently running line and the currently changing variables will be highlighted. Click on the icons
described in Step 1 to move through your program as you seem fit while noticing how the variables change.
1. We noticed that in this case the value of i has increased instead of decreasing. We’ll change this
Lab Report:
Use a thick hard binding lab copy for writing your weekly reports and submitting on the next lab day. Typical
components are:
a. Problem statement: Write the assignment description as given in the learning portal.
b. Class Diagram: Class diagram is a static diagram and it is used to model the static view of a system.
Generally, UML diagrams are not directly mapped with any object-oriented programming languages
but the class diagram is an exception. Class diagram clearly shows the mapping with object-oriented
languages such as Java, C++, etc.
c. Logic: In logic part algorithm or flowchart can be written.
An algorithm is unambiguous finite step-by-step procedure which is given input to produce output.
Typically algorithms are used to solve problems such that for every input instance it produces the
solution.
A flowchart is a type of diagram that represents an algorithm, workflow or process. The flowchart
shows the steps as boxes of various kinds, and their order by connecting the boxes with arrows.
d. Input/output: Input, output and also error handling should be written like this:
Error handling (for preventing wrong data processing) eg. Display error when n < 0
e. Test Cases: Test cases is defined as the output of the program. It should be written like this:
SL Test Case Expected Result Observed Result Status
1 Must start with a verb with Expected result when Observed result after Status should be Ok /
test data as applicable, e.g. the program will be running the program, Failed, e.g. Ok for
enter n value as 4) run, e.g. factorial e.g. factorial output this test case as
output should be 24 is 24 expected result and
observed result have
matched
Logic / flowchart:
Step 1: Start
Step 2: Declare variables num 1, num 2, and sum
Step 3: Read values num 1 and num 2
Step 4: Add num 1 and num 2 and assign the result to sum
sum <- num 1+ num 2
Step 5: Display sum
Step 6: Stop
Input/output:
Test Cases:
Class members (attributes and methods) have a specific visibility assigned to them:
For the above class, owner and balance attributes are private as well as the withdraw method. But we kept the
deposit method public, as anyone can put money in, but not everyone can take money out.
Notation of relationships:
Association: Relationship between two separate classes. There are four different types of association: bi-
directional, uni-directional, aggregation (includes composition aggregation) and reflexive. Bi-directional and
uni-directional associations are the most common ones. This can be specified using multiplicity (one to one,
one to many, many to many, etc.). Also, the relationship can be bi-directional with each class holding a
reference to the other.
Inheritance: Indicates that child (subclass) is considered to be a specialized form of the parent (super class).
For example, consider the following:
Realization/Implementation: A relationship between two model elements, in which one model element
implements/executes the behavior that the other model element specifies:
Dependency
Aggregation: a special form of association which is a unidirectional (a.k.a one way) relationship between
classes. The best way to understand this relationship is to call it a “has a” or “is part of” relationship. For
example, consider the two classes: Wallet and Money. A wallet “has” money. But money doesn’t neccessarily
need to have a wallet so it’s a one directional relationship.
Composition: A restricted form of Aggregation in which two entities (or you can say classes) are highly
dependent on each other.
A human needs a heart to live and a heart needs a human body to function on. In other words when the classes
(entities) are dependent on each other and their life span are same (if one dies then another one too) then its a
composition.
Multiplicity: After specificyfing the type of association relationship by connecting the classes, you can also
The above UML diagram shows that a house has exactly one kitchen, exactly one bath, atleast one bedroom
(can have many), exactly one mailbox, and at most one mortgage (zero or one).