Coursework 2: Critical Report on Object-Oriented Programming in Java

Verified

Added on  2025/04/22

|6
|1109
|191
AI Summary
Desklib provides past papers and solved assignments for students. This report analyzes OOP implementation in a Java-based GP surgery program.
Document Page
COURSEWORK 2: CRITICAL REPORT
Student name-
Registration number-
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Table of Contents
INTRODUCTION......................................................................................................................3
OOP CONCEPTS AND USE IN THE PROJECT -..................................................................3
DESIGN CRITERIA & APPROACH.......................................................................................5
CONCLUSION..........................................................................................................................6
REFRENCES.............................................................................................................................6
Document Page
INTRODUCTION
The appropriate GP SURGERY program has been developed using Java. This document will
showcase how the concepts of object oriented programming have been implemented and why
they were chosen. The document will also cover which approaches were used to cover the
requirements and how satisfactory the result was. The developed program covers all the
requirements and makes use of ArrayLists and TreeMaps to store data. Appropriate classes
and their methods have been created to produce the expected results.
OOP CONCEPTS AND USE IN THE PROJECT -
For the project concepts of object oriented programming have been used. Let’s start by
defining the basic concepts and showing where they have been used in the project.
CLASSES: A class in object oriented programming is like a basic layout for creating objects
of similar kind. The objects inside a class have a similar kind of nature and these classes are
also used to support the property of inheritance in programming. For the GP SURGERY
project three classes have been created which are:
Patient.java – This is a class where all the functions related to the patients reside. All
the operations performed regarding to patients will be defined here.
Doctor.java – Similar to the patient class, the doctor class contains all the functions
regarding to the doctors.
Main.java – This is the master class of the project and contains the main class from
where the project execution will begin. It also contains some other general function
declarations and variable declarations.
OBJECTS: An object in object oriented programming is a component containing properties
or methods or data. The object is an instance of the class with its own methods. Whenever we
send a message to an object, the object executes one of its own methods. For our project
multiple objects have been created at various places in order to invoke methods of that class
or to send data. (Baesens and Backiel, 2015) Example:
Patient patobj = new Patient(); //Creates an object of “Patient” type
patobj.findPatient(); //Object used to invoke method of its own
kind, that is of the type “Patient”
Doctor dt = new Doctor(); //Creates an object of “Doctor” type
dt.getAppointment(); //Object used to invoke method of its own
kind, that is of the type “Doctor”
Document Page
By creating objects of type patient and doctor, the respective methods of these classes can be
accessed into the main class.
POLYMORPHISM: This property of object oriented programming allows the processing of
objects based on the class they belong to or the data type. One method can perform different
actions based on the type of data it is receiving. Method overloading and Method overriding
are the implementations of polymorphism technique where overloading is static and
overriding is dynamic.
CONSTRUCTORS: These are member functions of a class which initialize the object. The
name for a constructor is the same as that of the class and they do not have a return type. We
can either define the constructor based on our requirements or let the compiler insert the
default constructor which will initialize all the values with the default value. A parameterized
constructor will initialize the object with certain values which may even be helpful in
constructor overloading. For this project, constructors have been explicitly written to
initialize the objects with some values. Example:
public Patient (String fname, String sname, String email, String phone,
String dob, String address, int id, int feePaid, String memberType) {
this.fname=fname;
this.email=email;
this.dob=dob;
this.sname=sname;
this.phone=phone;
this.address=address;
this.id=id;
this.feePaid=feePaid;
this.memberType=memberType;
} //Parameterized constructor for Patient.
This is a parameterized constructor for the Patient class. The objects of the type “Patient” will
be initialized with the values as mentioned.
PACKAGES: It is a way to bind together a group of classes. They are used to avoid naming
conflicts, making use of other classes easier and for providing controlled access. We can say
that they provide the functionality of data-encapsulation. For this project, a package Hospital
has been created and all the classes reside in that package. (Schuster and Tendyck, 2015)
Figure 1: Package Hospital containing all the classes
To include a class file into the package we just need to add “package package_name;” at the
top. Here the package has been created so that all the classes related to hospital can be bound
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
together. It allows ease of accessing other classes inside the same package and in case other
features regarding to something else need to be added in the same software, another relevant
package can be created.
DESIGN CRITERIA & APPROACH
A package named “Hospital” has been created which contains all the classes of the program.
The three classes are- Doctor, Patient and the Main class. To store the details of a doctor, an
ArrayList has been created. Similarly, the details of the patients are stored in another patient
ArrayList. ArrayLists provide dynamic arrays in Java, and are useful when multiple
alterations to data are needed. Unlike arrays we do not need to define the size of arraylists
and this was one of the major reasons behind using them in the project. They can shrink and
grow according to the size of the collection. (Joyce and Weems, 2016)
In this program, ArrayLists of type Doctor and ArrayLists of type Patient have been created
which store the complete data in the form of objects of type Doctor and Patient respectively.
Example :
List<Patient> patientList = new ArrayList<>();
List<Doctor> doctorList = new ArrayList<>();
TreeMaps have been used to store the appointment data. These treemaps store the data in the
form of pairs which are actually key-value pairs. Example:
private TreeMap<String,String> appointment=new TreeMap<>();
Here the key is the time for appointment and the patient name is the value being stored with
it. These values are retrieved and displayed by the getAppointment(); function.
Figure 2: Running program
Document Page
CONCLUSION
The program has been created with the use to arraylists and treemaps on Java. This was the
best approach on the basis of our learning yet and in the future a better use of inheritance
features of OOPS can be made to enhance code reusability and to make the program memory
efficient.
REFRENCES
Schuster, F., Tendyck, T., Liebchen, C., Davi, L., Sadeghi, A.R. and Holz, T., 2015.
Counterfeit object-oriented programming. In IEEE Symposium on Security and Privacy (Vol.
342).
Joyce, D.T. and Weems, C., 2016. Object-oriented data structures using Java. Jones &
Bartlett Publishers.
Baesens, B., Backiel, A. and Vanden Broucke, S., 2015. Beginning Java programming: the
object-oriented approach. John Wiley & Sons.
chevron_up_icon
1 out of 6
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]