Professional Documents
Culture Documents
ASSIGNMENT 03
Marks: 05
NAME:__________________________________________
CLASS:__________________________________________
REG. No._________________________________________
COURSE:________________________________________
Read Carefully:
• The deadline for this assignment is before or on Tuesday 25-05-21.
WARNING: This is an individual assignment; you must solve it by yourself. Any form of
plagiarism will result in receiving zero in the assignment.
WARNING: Late submission will not be accepted. Any assignment submitted after the cutoff
time will receive zero.
• You have to answer and submit in HARDCOPY of the given draft on your CR. And CR will submit
your assignement to your faculty on her given deadline.
1|Page
CS Department, BUKC 2/2 Semester 2 (Spring 2021)
CSC-210: OOP Assignment 03
Q1. Read the following given code carefully and answer the asked questions below it:
package valueobjects;
@Override
public boolean equals(Object obj) {
if(obj != null && obj instanceof Engine){
Engine engineToCompare = (Engine)obj;
if(this.consumption.equals(engineToCompare.getConsumption())
)
return true;
}
return false;
}
}
CS Department, BUKC 3/2 Semester 2 (Spring 2021)
CSC-210: OOP Assignment 03
package valueobjects;
import java.math.BigDecimal;
import java.math.RoundingMode;
public Parameter(double d) {
this.parameter = BigDecimal.valueOf(d).setScale(4,
RoundingMode.HALF_EVEN).doubleValue();
}
@Override
public boolean equals(Object obj) {
if(obj != null && obj instanceof Parameter){
double extracted1 =
BigDecimal.valueOf(((Parameter)
obj).getParameter()).setScale(0,
RoundingMode.HALF_EVEN).doubleValue();
double extracted2 =
BigDecimal.valueOf(this.getParameter()).setScale(0,
RoundingMode.HALF_EVEN).doubleValue();
if(extracted1 == extracted2)
return true;
}
return false;
}
}
CS Department, BUKC 4/2 Semester 2 (Spring 2021)
CSC-210: OOP Assignment 03
Q2. Answer the following questions: (answer should not exceed 3 lines) (2.5 Marks)
************END**************