Assignment 5
Assignment 5
Assignment 5
2. Write a program, which creates an instance of employee class and sets the values
for all the attributes.
• While setting value for empName, setEmpName() method should check for
NullPointer and display appropriate error message.
• While setting value for empDesig, the designation must have any of the following
values:
developer, tester, Lead or manager. If none of these values is matching then setter
method should display 'Invalid designation' error message.
• While setting value for empDept, the department must have any of the following
values: TTH, RCM, Digital, DevOps. If none of these values is matching then
setter method should display 'Invalid Dept' error message.
Develop a program that assists bookstore employees. For each book, the program
should track the book’s title, its price, its year of publication, and the author’s
name. . . . Develop an appropriate Java Class. Create instances of the class to
represent these three books:
XYZ bank wants to maintain customer details. It will register the customer details
whenever a person opens an account with the bank. Below is the customer class
diagram:
At times, the customer registration process changes, here are the guidelines:
1. Admin may register customer by filling only ID, name and address details 2.
Admin may register customer by filling only ID and name
Note: When other data members which are not initialized through constructors
should have appropriate default values.
Objective:
Given a class diagram for a problem, use the method and constructor overloading
concepts to solve the problem and test using a set of values in an IDE.
Student
-studentId: int
-studentName: String
-marks: float
-secondChance: boolean
+Student(int,String,String)
Student Class:
identifyMarks(float) method:
This method is used to set the marks of the student if the student has cleared in the
first chance itself, i.e. second chance is false. This method accepts the marks
scored by the student which must be set in the marks instance variable.
identifyMarks (float, float) method:
This method is used to set the marks of the student if the student has taken the
second chance i.e. second chance is true. This method accepts the marks scored by
the student in the first chance and second chance. The maximum of both these
marks must be identified and set in the marks instance variable.
Starter Class:
Step3: Invoke the getter methods and display all the instance variable values of the
Student object created. Create one more object (use different value for second
chance) by repeating steps 1 to 3 and test your program.
Exercise 34: Design and implement applications using basic OOP paradigms.
Create a method which accepts array of ‘Student’ objects and returns Student
object who has scored highest marks.
• ID
• Name
• Branch
• Score