Report: Object-Oriented Design Choices in Future College App

Verified

Added on  2023/05/28

|13
|1508
|247
Report
AI Summary
This report provides a comprehensive analysis of the object-oriented design choices implemented in a future college application. It delves into the application of key OOP concepts, including encapsulation, polymorphism, and packaging, illustrating their usage with code snippets and screenshots. The report examines the design choices, evaluating their effectiveness and efficiency in the context of the application's functionality. It also provides an assessment of whether the chosen design principles were appropriate and discusses alternative approaches. The report concludes with a reflection on the overall development process, including the use of Java for object-oriented programming, and whether the design choices were optimal, offering insights into the strengths and weaknesses of the implemented design. The report is a great resource for students seeking to understand and apply OOP concepts in software development.
Document Page
Name
Institution
Course
Instructor
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
Encapsulation..............................................................................................................................................4
Access modifiers......................................................................................................................................5
Constructor..............................................................................................................................................6
Method....................................................................................................................................................6
Polymorphism.............................................................................................................................................9
Packaging...................................................................................................................................................11
Choices......................................................................................................................................................12
References.................................................................................................................................................13
Document Page
Introduction
The report elaborates on the object-oriented design choices made in implementing future college
application. The object-oriented design choices made are encapsulation, polymorphism, and
packaging of the classes in the program. Codes and screenshots to verify the use of the OOP
concepts are pasted in the report. The report also contains an answer to whether the choices for
the design were correct or wrong.
Document Page
Encapsulation
Encapsulation has been used in the future college console program. Encapsulation is the
packaging of codes, variables, methods and related data and information as one unit of execution
(Santos, 2014). This has been done with the use of classes, methods, and constructors in the java
codes below. The classes consist of get, set and return methods, constructors and access
modifiers.
Future college program has many classes that contain methods, constructors, access modifiers
and variables. The classes are course manager, enroll manager, pay fees manager, student
manager, course, enroll, pay fee, student, future college, Course io, enroll io, pay fee io, student
io and student console.
The classes are of great significance in the future college program because they are used to store
data on various objects and entities. This has been done through the use of get and set methods
used in the classes in the program.
The following codes and screenshots show the use of classes
public class Course {
private int id;
private String name;
public Course(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
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
Screenshot
Access modifiers
Variables, methods, and constructors declared private cannot be accessed by a method,
constructor or variable declared outside that class or any other class in the system.
Variables, methods, and constructors declared public can be accessed by a method, constructor
and variable declared outside the class. They can also be accessed by any other class in the java
program.
Document Page
Constructor
A constructor is an instance of a class that does not have a return type (Ghosh, no date). For
instance, public Course (int id, String name ){this.id = id; this.name = name;} is a constructor or
an instance of class course.
public Course(int id, String name) {
this.id = id;
this.name = name;
}
Constructors are very essential in the future college program because they are use to initialize the
classes in the program.
Method
A method is another way of implementing encapsulation. A method is a block of code that has
parameters inputs, outputs and return type (Bluemke and Kulesza, 2011). A method can be static
or void. Void methods have no return type.
Future college program has utilized the use of methods in its implementation. The following are
examples and screenshots of the methods in the program
public int addCourse(Course c){
this.listOfCourse.add(c);
return count();
}
public int count(){
return this.listOfCourse.size();
}
Document Page
In the class course manager, addCourse and count are methods. addCourse adds a course to the
list of available courses and count counts the number of courses in the course list.
In studentConsole class, removeStudent is a method that gets the student ID from the user
through the use of the Scanner and removes the student from a certain course enrollment list.
private void removeStudent() {
System.out.println("Enter ID :");
int id = readInt(0, Integer.MAX_VALUE);
boolean result = this.sm.removeStudent(id);
if(result){
System.out.println("Student was removed from course");
}else{
System.out.println("Student not found");
}
Screenshot
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
From the above screenshots and bits of code, methods were used to perform operations and
manipulations on the objects, variables, and entities defined in the classes in the program.
Document Page
Polymorphism
Polymorphism has been utilized in the Future college console system. Polymorphism is the
existence of an object in more than one form (Connor et.al; 2012). Polymorphism in a program
can be achieved in two ways
Through method overloading or constructor overloading
Through method overriding or constructor overriding
Overloading is where methods use the same identifier, declared in the same class but differ in
their inputs and outputs whereas overriding is where methods and constructors use the same
identifier, the same inputs, and outputs but are declared in different classes. Overriding is
commonly used in super and subclasses.
Future college program implements polymorphism through constructor overloading where the
constructors are declared in the same class, have the same identifier but have different inputs and
outputs.
Example
Student manager constructor overloading
public StudentManager() {
this.listOfStudent = new ArrayList<>();
}
public StudentManager(List<Student> listOfStudent) {
this.listOfStudent = listOfStudent;
}
Screenshot
Document Page
The first constructor with no parameters is used to declare a new list of students whereas the
second constructor with List of Students as the parameter is used to initialize the list of students.
Course manager constructor overloading
public CourseManager() {
this.listOfCourse = new ArrayList<>();
}
public CourseManager(List<Course> listOfCourse) {
this.listOfCourse = listOfCourse;
screenshot
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
Packaging
A package is a group of related objects in Java (Ghosh, no date). Packaging is done to facilitate
easy access to related classes or interfaces in a program and avoid naming mistakes.
The Future college program is an example of implementation of packaging because related
classes in the program have been packaged into packages. Future college program has five
packages; controller package, entity package, future_college package, IO and UI packages that
contain related classes.
Controller package consists of four classes; course manager, enroll manager, pay fees manager
and student manager. Entity package consists of four classes; course, enroll, pay fee and student.
Future_college consists of one class future_college. IO package has four classes while UI has
one class.
package future_college;
import ui.StudentConsole;
public class Future_College {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
StudentConsole sc = new StudentConsole();
sc.start();
}
}
Document Page
Choices
Looking back at the console program, the right choices were made. Using Object-Oriented
concepts; Encapsulation to hide data, Polymorphism and packaging was very effective and
efficient in implementing a functional future college console application. Given an obligation to
develop a similar program I’d use the same concepts of OOP. Object Oriented concepts make the
design and implementation of a program easier and more accurate in terms of adhering to
requirements.
chevron_up_icon
1 out of 13
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]