










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
this is the full programming assignment, talks about object oriented and every thing you need to know about OOP, do not copy the codes.
Typology: Assignments
1 / 18
This page cannot be seen from the preview
Don't miss anything!











All sources will be found in the last page of this document
1.1: Define what an algorithm is and outline the characteristics of a good algorithm To begin with, we should have a clear idea of what an algorithm is in order to decide what truly makes a good algorithm. In the vast world of computer and information science, algorithms are fundamental to our skills. Basically an algorithm is a sequence of steps used to solve a problem but according to the book “Algorithms for Dummies” by John Paul Mueller and Luca Massaron, this sequence of steps presents a unique method of addressing an issue by providing a particular solution; and in order for a process to present an algorithm this process must be: finite (solve the problem correctly), well-defined (the steps
must be clear and understandable) and effective (must solve all cases of the problem) (1)^.
You might not notice it but algorithms are all around us in our daily lives, for instance when you’re following a sequence of steps for baking a cake you are technically following an algorithm and the baked cake is the outcome/output. What makes a good algorithm? All algorithms follow the same basic outline:
1.3: Describe the steps involved in the process of writing and executing a program When I want to write a program I ponder as to what my program is going to be used for, will it be simple or tough for me to achieve? I start by outlining the problem then I begin planning possible solutions , I tend to choose the simpler / less complicated route after that I begin typing down the code then shortly after running the program. The initial test run isn’t always perfect so this is where I document my flaws and see what I can do to make them better. After multiple trials and errors we tend to reach a point where the code is working perfectly and is ready to finally be executed. 1.4: Java program for encryption and decryption GitHub depository: https://github.com/sajaalshammari/forProgrammingFinal
1.5: Evaluate the above implementation of the algorithms and the relationship between the written algorithm and the code Referencing the screenshot of the code in part 1.4 and relating it to the pseudo code in part 1. In lines 14 and 16 I am scanning an integer and string from the user respectively. In line 21 this is where I change the string taken from the user to an array of characters using the toCharArray method. In line 23 , I am iterating this character array and in each character or index and in line 24 I am adding the key taken from the user which in this case is 4. (Related to ASCII code as mentioned above) line 25 is where I print each character to show the encoded message. Line 29 , that same character array is now stored as the encrypted version so here I am also iterating that array using a for loop and in line 30 I am doing the exact opposite of line 24 , where we were adding the key now we are subtracting to get the message back to original. Line 31 is where I print each deciphered character.
2.1: Define what is meant by a Programming Paradigm. Explain the main characteristics of Procedural, Object oriented and Event-driven paradigms and the relationships among them: To begin with, some synonyms for “paradigm” include: a sample, a prototype or a pattern. According to Wikipedia.org, programming paradigms are a way to classify or distinguish between programming languages based on their features for example:
Encapsulation: Completely hide complexity and details inside a class using private methods and access modifiers (Private, Public, Protected and Default). Advantages include: o Making completely private attributes and methods; enhances security. o Programmer makes code read only access or write only access (no one can access from outside of the class). o Helps developers organize the entire code easily (3). Abstraction: Hide implementation and irrelevant details found in the code from the user, making the interface simple. Uses loosely coupling classes (classes are almost, not fully, dependent of each other) (4)^ and focuses mainly on what should be done. Inheritance: Is the process where one class (child class) inherits characteristics from another class that we tend to call a parent class, this concept is very helpful especially when code is being reused between different classes and is used for method overriding (when a child class and a parent class have the same method declared) which takes us to polymorphism. But first, some advantages of Inheritance include: o Inheritance promotes code reusability which leads to less development and maintenance cost (5). o Better organization of code, improves program structure and is easy to read. o “Facilitates the creation of class libraries” (6)
Polymorphism: “ Is the ability of an object to take on many forms” (7)^ and is used for implementing inheritance. For example, here I am making an object, logically speaking, a rectangle and a triangle are shapes, the parent class is “Shape” and the sub classes are triangle and rectangle creating a hierarchal inheritance (8).
So, as seen in b) this is where polymorphism takes place, we declare the object as Shape with reference “rec” but the creation of the object will be from Rectangle class. Advantages of Polymorphism include: o Programmer can reuse the code and as many times as required o Time-optimal o Easy debugging process o “Helps in reducing the coupling between different functionalities” (9).
3. Event-Driven programming As the name suggests, this programming paradigm is driven on events that could be a user-action or time-based. This paradigm works by “listening” and waiting for an event to occur and based on that we decide how to handle this event. Event-driven is mainly used to make GUIs (Graphical User
Rectangle Class
Triangle Class
Shape Class
a) Hierarchal Inheritance b)^ Example of polymorphic objects
case seeing if the number inputted matches any of the case values, if there is a match…a function is called. Object-Oriented: for this paradigm I have also prepared a little game that I vaguely remember from my childhood known as “Tikken”, there are two characters and you get to choose who to play with against the other choice (that you didn’t choose). The main focus of this program is Hierarchal Inheritance where the class “Damage” contains standard values of the amount of damage a player could do with Kick and Punch then the class “Azuka Kazama” inherits that damage and since her specialty is kicking I have multiplied the standard kick damage by 10, I do the same with her punch and special move but interpreting other mathematical procedures. The same goes for the class “Jin Kazama” where he is also inheriting from the “Damage” class. In the class “Gameplay” the creation of the objects take place and the two characters fight each other; I feel like I could have added extra features like a health bar or for the two to fight till one of the characters’ health reaches zero, by subtracting the damage done from the health. Event-Driven: I chose an extremely simple way to show how this paradigm works, I mainly kept in mind what the user might like to see so I thought of some fun facts and categories that are: Art, Animals, Programming, and Space. The action listener waits and listens for you to click a button and when you do, a specific task is implemented, in my case it shows a pop-up message containing a fun fact relating to the category the user’s choice. I notice that this paradigm has some OOP related to it like Overriding and calling methods from pre-defined classes. I really like this paradigm because the end result is always rewarding to see and fun to play with.
3.1: GPA calculator GitHub depository: https://github.com/sajaalshammari/forProgrammingFinal
3.2: Evaluate the use of IDE for development in contrast to not using an IDE In my personal opinion, the use of an IDE is unbelievably convenient, in the span of my two semesters in Information Sciences I have taken C language using a virtual machine Text Editor and Java Eclipse IDE, so I will be subtly comparing these two mechanisms. In C, after we write the entire program we would compile this program using a gcc compiler that we had to type down in the terminal, it is in that moment when it shows us where our errors are in the code we typed down, sometimes the error would be just forgetting a semicolon and to be honest that was quite time consuming. With IDE it points out the errors while you are coding / typing down the code so that you are able to fix or touch up your program before running it which happens with a press of a button.
Syntax errors occur when the code typed down doesn’t follow the structure of the programming language and the beauty of IDE is that it shows this type of error before running the program, for example: Example i:
In line 18, I have forgotten a semicolon,it creates a red line underneath highlighting where the syntax error is
When you hover over the error, it gives you the type of error and the solution
3.3: Explain the Debugging process you followed in writing your programs: “ Debugging is the process of finding and resolving bugs (defects or problems that prevent correct operation)
within computer programs, software, or systems.” (10)
Using Eclipse IDE offers tools that help us in debugging codes, these tools include: a. Breakpoints: we place break point on specific line of code so that when we are running or debugging the program, it pauses at the point we chose. Breakpoints act like starting an end points.
b. Step Over: basically moves you from one line to the one underneath, based on the breakpoints you have set.
c. Step Into: Is similar to step over but it comes with an extra feature, when you reach a function this tool will help you “step into” the function. It will sometimes take you to the original class the function came from this is mainly with pre-defined functions by java. From line 18, I pressed step into and it took me to the Scanner.class
First breakpoint placed on line 15 Moved me to second breakpoint which is on line 18
Step Over
d. Step Out: will basically take you back to the original function (if step into was used) and if you are done debugging.
Why debugging is beneficial:
Debugging prevents incorrect system / software operations (14)^ and logically speaking, a program with no bugs is definitely more secure than a program with a lot of errors and bugs. Debugging helps in making a coherent program that runs fluently and thanks to the tools in IDE using and making programs comes at an advantage to the user and developer. I honestly do consider these tools very helpful, they personally helped me with my time because if I were to debug my programs on my own it would’ve taken me double the amount of time, IDE also picked up errors that I wasn’t able to notice, it is over all very beneficial and I see myself using it in the future especially in shared programs with a project team, since we have to mainly focus on the project and not on external factors that could potentially act as a set-back for the progress the team has achieved.
Coding standards (11):
Majority of information and computer science jobs and projects (related mainly to programming) will be shared with a group of employees, we are talking about a code that goes through multiple implementations by different people and these people won’t have the time to explain to you the
Step Out
Scanner.class Back to line^18
I also use comments so I can keep track of each variable and what they are used for:
Another coding standard includes mathematical functions , like the use of order of operations and brackets, for example:
Which one seems more understandable? It is clear that we need to divide the average by 100 then multiply by 4. To summarize, we can clearly see how beneficial coding standards are, not only between different programmers but also to myself. Following a coding standard makes everything easy to read and straight forward and I think that we should all follow these standards in order to have clarity and an outline of how the code functions.
The return statement could’ve also been written like: stuAvg/100*
References: Bibliography (1) Mueller, J. and Massaron, L., 2017. Algorithms for dummies. 1st ed. Canada: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, pp.11-15. References (2) TechGeekBuzz. 2021. What is Procedural Programming? - Techgeekbuzz. [online] Available at: [Accessed 16 June 2021]. (3) Guru99.com. 2021. Difference between Abstraction and Encapsulation. [online] Available at: [Accessed 16 June 2021]. (4) Das, M., 2021. Coupling in Java - GeeksforGeeks. [online] GeeksforGeeks. Available at: [Accessed 16 June 2021]. (5) Sparrow, P., 2021. Pros and Cons of Inheritance in OOPS. [online] Ianswer4u.com. Available at: [Accessed 16 June 2021]. (6) Bhatia, V., 2021. What are advantages and disadvantages of using inheritance? | Practice | GeeksforGeeks. [online] Practice.geeksforgeeks.org. Available at: [Accessed 16 June 2021]. (7) Tutorialspoint.com. 2021. Java - Polymorphism - Tutorialspoint. [online] Available at: [Accessed 16 June 2021]. (8) www.javatpoint.com. 2021. Inheritance in Java - Javatpoint. [online] Available at: [Accessed 16 June 2021]. (9) Sparrow, P., 2021. Advantages & Disadvantages of Polymorphism in OOPs. [online] Ianswer4u.com. Available at: [Accessed 16 June 2021].