Landing : Athabascau University

Reflection 2

  • Public
By Mahmooda Malik October 19, 2023 - 8:49pm

Reflection 2

Notebook

 

 

For me programming is a journey of proficiently solving problems that involves creativity and getting used of a completely unknown Jorgen. As I earlier stated that during my university years, I had to struggle and part of the reason was that I had no help. If I was stuck at some point on my assignments, there was no help from my TAs. The other reason was that we had to take many courses simultaneously so we never had enough time to think through the problems. We were never given enough skills to write short programs. We were just given overwhelmingly big scary assignments to write code.  For me programming became a nightmare. I read books, I tried to seek as much as I could but no matter how hard I would try I would just barley passing marks.

 

However, Now that I have more time and I think the textbook is very well written and the given problems are simple.  I am able to understand better.  

 

In this assignment, for some questions, I was able to program quickly but for some of them especially for the question where we are asked to create point classes and the shape class. I struggled a lot but finally I was able get the output.

 

 

Quesiton1:

 

 

This question asks, to use animal class, with different child classes. So first, I created a main class, with the public static void class, in this class, I defined the variables using normal methods of variable assignments. I defined each animal and then I created assignment for each type of animal. I learned Array is more helpful because I can just write an Array and a simple loop to output all animal child classes with their specific attribute.  It was a lot of work but when I started reading about the Arrays. My Array had four items in it. So the length of the Array was 4. Then I used a for loop to execute the items in the array with their behavior type using sound() function.  I created an animal interface class. In this class I described the two animal behaviours by using the public void (). Next, I created sub-classes or child classes for each animal type. Then I linked each type of animal class to the interface animal class by using word implement in the public class.  So, each animal behaviour was linked to the interface via implement.  By implementing each class let me call the @Override function which helped me implements the special attribute or behaviour of each animal type in the parent class.  

 

Question2:

 

Problem 2 was similar to problem 1. Here I created two classes, a main and the other with all the books that were my absolute favourite. In main class, I created object classes for each book, inside the assignment brackets, I added the attribute of each book. Then System.out.println () was used to print each book on the screen. Next, in the subclass, I first defined all the private variables including “Book title”, “author”, “isbn”, “publisher”, and “year of publication”. Next, I used a Constructor, this method was used to initialize the objects for a class.  To my understanding a constructor is like a real life constructor worker and the variable assignment that it gets is like all the things that a construction worker needs to construct something.  Constructor gets the same name as the class and there is no return type for it. I used getters/setters under constructors. Getters/Setters validate and maintain the state of an object.

 

continues....