Computer Science

Taught by Mrs.Tarrico, the Computer Science course at Mass Academy covers web design, object oriented programming, and app development. In our first term, we design and creat our personal websites using HTML and CSS. During B-term and C-term, we learn the fundamentals of coding in Java. We end the year with Apps for Good, a group project in which students create apps to remedy a problem.

Stars.java

For this assignment, I created a class that uses Java graphics to draw 10 stars of random size and color. The stars are created by specifying center coordinates for the star and a radius. Using some trigonometry, the 5 vertices are calculated, and a random color is independently specified as well. Then the fillPolygon(); function from the Java graphics class uses these 5 vertices and color to draw the star. This algorithm is repeated 10 times with random centerpoints, radii, and colors, resulting in the output below:

Stars

BulgarianSolitaire.java

In this Java class, we had to model Bulgarian Solitaire. The game starts with N amount of cards, which are split into a random amount of piles with random amounts of cards in each pile. If you had 45 cards, you might split the cards into 5 piles with piles sizes of 20, 5, 1, 9, and 10, for example. Then, you take away one card from each pile and create a new pile with all of the subtracted cards. For instance, if you continue with the example prior, after subtracting 1 card from each pile and creating a new pile with the subtracted cards, you have five piles with sizes 19, 4, 9, 10, and 5. The solitaire is over once you have pile sizes 1, 2, 3, 4, 5, 6, 7, 8, and 9, in some order. N has to be a triangular number for this to work. The simulation had to produce and print a random starting configuration and run the solitaire algorithm until the final solitaire configuration was achieved.

Bulgarian Solitaire Output

Apps For Good

People who are hard of hearing are unable to fully experience music because of their lower audio sensory ability. Many of these individuals are left out of important parts of their culture and modern life due to the disability. The target audience of the app is deaf individuals ranging from children to elders. The app allows users to pick their song of choice and then receive their visualization, which will translate features of the song into visual senses. Based on that solution, our minimal viable product was this: the app shall be able to visualize the music and play the audio of the music in synchronization.

Our visualization created a rectangle for each note on a plot, where the x-axis was time, and the y-axis was the pitch of the note. Our app had two algorithms to create the visualization. The first one was built using Python and uses the MIDO library to parse a MIDI music file to get information, such as the pitch, duration, and start time, for every note in the song. That information was then transferred to the Java part of our app. The Java aspect of our algorithm used the three types of music data to find the coordinates for each rectangle that represented a note. The rectangles were drawn onto a canvas on the Android app's screen. The pitch determined the rectangle's y-coordinates, the start time determined the left x-coordinate, and the duration determined the right x-coordinate. To animate the rectangles, the app refreshed the canvas every 50ms and translated the rectangles 5 px. The music also played in parallel when the animation ran.

Presentation