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....
The Landing is a social site for Athabasca University staff, students and invited guests. It is a space where they can share, communicate and connect with anyone or everyone.
Unless you are logged in, you will only be able to see the fraction of posts on the site that have been made public. Right now you are not logged in.
If you have an Athabasca University login ID, use your standard username and password to access this site.
We welcome comments on public posts from members of the public. Please note, however, that all comments made on public posts must be moderated by their owners before they become visible on the site. The owner of the post (and no one else) has to do that.
If you want the full range of features and you have a login ID, log in using the links at the top of the page or at https://landing.athabascau.ca/login (logins are secure and encrypted)
Posts made here are the responsibility of their owners and may not reflect the views of Athabasca University.