emmaxshen / APCSA_Blog

MIT License
0 stars 0 forks source link

FRQ Connections to PBL + Reflection #2

Open emmaxshen opened 6 months ago

emmaxshen commented 6 months ago

Show how FRQs or principles of FRQs are incorporated into to your final project.

FRQ 1: Arrays/Array List


This FRQ was testing understanding of how to use 1D and 2D arrays in the context of iterating through them, accessing the elements, and using nested loops and conditional statements to reach the desired outcome (check whether or not elements of an array are diverse). For my group's cybersecurity educational game website, the code below functions to retrieve all game sessions for the particular game, calculate the minimum session time for each user, and return a sorted leaderboard that ranks each user by how fast they were able to complete the game.

image

In our code we did not explicitly use 1D or 2D arrays; however, we did use Lists and Maps in the context of Java Streams that conceptually reflect principles similar to working with 1D arrays. The List<Gamesession> sessionList serves as a collection, analogous to a 1D array, containing game session data. The iteration through the sessionsByUId Map involves traversing the keys (user IDs) and their associated values (lists of game sessions), similar to iterating through a 1D array and accessing its elements. We also did use a nested for loop for each user iterates through a list of game sessions (gList) and used a conditional if statement within this loop to check for the minimum session time.

One integral part of this code that deviates from college board knowledge was our decision to use a tuple (Tuple2<Long, Double>) (which I learned is a built-in data type that allows you to create immutable sequences of values) since it allowed us to pair user IDs with their corresponding minimum session times in an organized bundled manner.

FRQ 2: Classes


This FRQ was all about knowing what are the necessary components for a Java class which include the private instance variables, constructors, and main method. In our PBL we used this framework for many different features but most prominently we used it for the login feature. In the code segment below we declared the public class Person that holds information on their user ID, birthday, and two strings for their email and password.

image

Here we can see the use of a parameterized constructor that holds all of this user information to build object from the API. A custom getter method is also used to return the age of user after doing calculations from their date of birth input

image

I would say that the anatomy of our Person class is quite standard to other login systems with the use of some variables, constructors, and getter methods.

FRQ 3: 2D Array


This FRQ introduced the idea of sparse arrays to me. For my own understanding in simple words, I see it as a big matrix with mostly 0s and in order to not bother with all that memory you just track the nonzeros (the picture below really helped me visualize). I believe its main function is to efficiently represent and store arrays where the majority of elements have a default value.

image

In our project, we have not explicitly implemented any sparse or 2D arrays. However, I believe we could implement it when we complete our "spot the difference" game for phishing attack emails. When the game displays two similar images and the player's task is to identify the differences between them, we can represent these images using a 2D array of pixels. Further, as the player advances to higher levels and there are only a few differences between the two pictures we can use a sparse array to optimize storage! It could work something like this:

# Using a dictionary to represent a sparse array
sparse_difference = {
    (1, 3): 0  # (row, column): value
    # ... other differences
}

When the player points to a location (row, column) and claims there's a difference, you can check their input against the sparse array.

def check_difference(player_input, sparse_difference):
    return player_input in sparse_difference

FRQ 4: Methods & Control Structures


For this one I was a bit confused on what differentiates this type of FRQ from the classes type FRQ because it seemed to just have me go through the same process of building a class, initializing instance variables an constructors, and using iterative statements to achieve the goal of figuring out if an integer was in a NumberGroup. After some google searching I learned that one way to see a difference is that: A class can implement multiple interfaces, but it can only extend a single class. If you need a class to inherit behavior from multiple sources, interfaces provide a way to achieve this.

In our project, we definitely used a public interface for the log in feature, but I thought I should highlight the use of "public interface Link extends JpaRepository<Template, Long>" in my feature that mimics when in the FRQ I did "Range implements NumberGroup". My feature was about taking user input of what kind of operating system they had and then displaying useful information about how to combat certain vulnerability issues they were facing.

image

Here, the code segment above showcases the use of method control structures in the context of a Spring Data JPA repository interface (Link). It extends a generic repository interface (JpaRepository) to inherit standard CRUD operations and includes a custom query method for fetching data based on the operating system name. I think this is a pretty standard way that shows the way inheritance can lead to greater code efficiency.

Overall Reflection on FRQ & PBL


F1nnC commented 6 months ago

Your project about cyber security is really interesting. I hadn't really seen your group's project and it's interesting how we both pursued the game route for learning but ended up doing completely different things. Of course, ours is more based of APCSA circulium and is an RPG-style game. Although your code is giving me ideas on how to make little mini games for our players. I think the battle sequence that I created could get stale so maybe around the map I should add minigames similar to what you made to make the game easiser to newcommers.

Your Code looked good and it looks like it all relates to the college board exams.

3.6/4 Cool Project