Tuesday, July 2, 2024

CST 338 - Week 2

This week we worked on parts 1 (Book.java) and 2 (Reader.java) for our first project in the class which stores, manipulates, and analyzes information stored within a library. I didn't really have any issues, except for not realizing there was an enum class I needed to use. We will finish up Project 1 in the coming weeks by completing Shelf.java, and Library.java.


We also had to complete our first heavy homework assignment, Histogram, which reads a text file from a user and displays a histogram from the occurrences of characters in the file.

I never really ran into issues passing the unit tests, but I spent too long trying to implement a solution for taking the numbers from counting the letters, removing all duplicate numbers, and then printing them in descending order, so instead of 1 2 3 4 4, it printed out 4 3 2 1. I imagine I was overcomplicating the solution and there was a much simpler way to go about it. 

After trying a few different solutions and still having trouble, I thought I would use a HashMap to store the unique numbers as keys and then return those unique keys. However, I still encountered issues. While working to figure out what was wrong with my HashMap, I learned about LinkedHashSets and how they don't include repeating elements, and return the output in the same order it receives the input. This solution ultimately worked for me, but again, I feel I was overthinking the problem, and there was probably an easier way.

Going forward, I will try and spend a little more time thinking of possible ways to solve the problem and why my current approach is not working, instead of getting frustrated and constantly going through numerous methods to solve the problem.


No comments:

Post a Comment

CST462S - Service Learning Experience

With the first half of my Summer semester now coming to a close, I am submitting my final assignments and preparing for the upcoming class i...