TayKimmy / CSA-Repository

MIT License
1 stars 0 forks source link

2015 FRQ Connections to PBL #13

Open TayKimmy opened 4 months ago

TayKimmy commented 4 months ago

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

FRQ 1 - Arrays + ArrayLists

This FRQ was focused on ArrayLists, 1D Arrays, and 2D Arrays. It added the sums of each row in the array and saw if the sums were diverse or not. In our PBL project, we have a couple cases of ArrayLists an 2D Arrays. One of the main ones is in Person.java, where we use an ArrayList to store the roles of users.

@ManyToMany(fetch = EAGER)
private Collection<PersonRole> roles = new ArrayList<>();

The ArrayLIst stores the PersonRole objects for each user and enables users to have multiple roles, such as student and admin roles. We also utilize an ArrayLIst for our ASL project in PredictionService.java.

private List<List<Integer>> readCSV(String fileName) throws IOException {
        List<List<Integer>> data = new ArrayList<>();
        try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
            String line;
            boolean isFirstLine = true; // To skip the header row
            while ((line = br.readLine()) != null) {
                if (isFirstLine) {
                    isFirstLine = false;
                    continue; // Skip the header row
                }
                String[] values = line.split(",");
                List<Integer> row = new ArrayList<>();
                for (String val : values) {
                    try {
                        row.add(Integer.parseInt(val.trim()));
                    } catch (NumberFormatException e) {
                        System.out.println("Skipping non-numeric value: " + val);
                        // Handle the non-numeric value, or continue
                    }
                }
                data.add(row);
            }
        }
        return data;
    }

This code uses an ArrayList to store CSV data where each element contains a list of integers that represents a row in the CSV data. For each line in the data, a new ArrayList named row is created and will store the integer values for the current row. Using a loop, each string value in the current line is converted to an integer and added to the row ArrayList. After all data is processed, the row ArrayList is added back to the original data ArrayList.

Arrays and ArrayLists are important data structures that are not just used by Collegeboard. We use them in our PBL projects because of how important and essential they are. Our use of ArrayLists and arrays are similar to the FRQ because they both require iterations over lists of integers.

FRQ 2 - Classes

This problem asked for class creation to create a word guessing game that was like Wordle because of the type of hints it gave. The player would guess a word and based on which letters which correct and whether the positions were right, different hints were given. Our project also utilized classes several times. Here is one example in our Frame.java

@Entity
public class Frame {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String mnistData;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getMnistData() {
        return mnistData;
    }

    public void setMnistData(String mnistData) {
        this.mnistData = mnistData;
    }
}

Our class in our project, similar to the one in the FRQ, contains instance variables and methods. Our class creates variables for the id and the mnistData, which is important to our project.

Overall, classes are also important and necessary to Java and this FRQ emphasizes the structure of classes.

FRQ 3 - 2D Arrays + Method and Control Structures

This FRQ asked about 2D arrays - specifically sparse arrays - and had us do a variety of functions such as removing columns or retrieving the values based on the row and column. 2D Arrays are not used as much in our project but we do use it to train our data in PredictionService.java.

public String trainLogic() {
        System.out.println("---------trainLogic");
        List<List<Integer>> data = new ArrayList<>();
        try {
            data = readCSV("sign_mnist_train.csv");
        } catch (IOException e) {
            System.err.println("Error reading CSV file: " + e.getMessage());
            // Handle the exception, e.g., log it or return a default value
            return "Error"; // or any other error handling mechanism
        }
        int lg = data.size();
        int lg1 = data.get(0).size();

        int[][] x = new int[lg - 1][lg1];
        for (int i = 0; i < lg - 1; i++) {
            for (int j = 0; j < lg1; j++) {
                x[i][j] = data.get(i + 1).get(j);
            }
        }

Our trainLogic method utilizes 2D arrays to perform its function. Using the data from the CSV files, we create a 2D Array with the rows being the length of the data and the columns being the length of the first row in the data. We then iterate through the rows and columns using nested for loops to populate the 2D Array with the values from the data.

2D Arrays are helpful in Java and we utilize them because they easy and efficient to use to train data. We could maybe implement 2D Arrays more outside of the data training and maybe use it to store info about users and their game scores.

FRQ 4 - Methods and Control Structures

This problem was centered around interfaces and implementing that interface into different classes. The interface had a contains method that we used in our implemented classes. The 2 classes - Range and MultipleGroups - implemented the NumberGroup interface and had different code for the contains method. In our project, we use inheritance a couple of times - mainly in any of the Jpa repositories because they extend from the JpaRepository (i.e. FrameJpaRepository extends JpaRepository). An example is in the PersonJpaRepository,java.

public interface PersonJpaRepository extends JpaRepository<Person, Long> {
    Person findByEmail(String email);
    Person findByUsername(String username);

    List<Person> findAllByOrderByNameAsc();

    // JPA query, findBy does JPA magic with "Name", "Containing", "Or", "Email", "IgnoreCase"
    List<Person> findByNameContainingIgnoreCaseOrEmailContainingIgnoreCase(String name, String email);
    List<Person> findByNameContainingIgnoreCaseOrUsernameContainingIgnoreCase(String name, String username);

    /* Custom JPA query articles, there are articles that show custom SQL as well
       https://springframework.guru/spring-data-jpa-query/
       https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods
    */
    Person findByEmailAndPassword(String email, String password);
    Person findByUsernameAndPassword(String username, String password);

In the code above, the interface PersonJpaRepository uses inheritance and extends from the JpaRepository. A different from the FRQ is that we use extends instead of implements. Either way, both demonstrate inheritance and greater code efficiency by eliminating the need to write more lines of code and adding more unity to properly function.

Reflection

Through these FRQ's, I realized that I still have a lot I need to improve in. But, it also helped me realize how much I grew since the beginning of the year when I could barely even answer 1 question.

Compared to before, doing the FRQs was easier, and I finished quicker. But, I still had to look up several functions and methods for me to get the code up and running. I still need to work on timing as well so that I can finish the 4 problems in the proper time instead of taking as long as I want. Mainly, I just need more Java practice in general to get more used to the syntax and different methods. Taking the FRQ also helped me realize that I can't just memorize problems and answers, but I have to actually have an understanding of the concepts and how they all connect for me to really succeed on these FRQs.

I also learned the connection these FRQs have with our PBL projects we do in class. The PBL Projects and the FRQs should both be used to improve my understanding of the concepts and I should start reflecting on the implementation of the concepts in our projects. I will also be doing more practice FRQs to improve my efficiency and better prepare myself while also increasing my knowledge on the concepts and helping me contribute more to the group projects.

DasMoge124 commented 4 months ago

FRQs

Commented by Kevin Du
FRQ Score and Explanation
1 0.9/.9 Had a complete FRQ Running with all parts complete. A Collegeboard example was used to demonstrate full usage. Used Hashmaps for diverse arrays, didn't think of using it.
2 0.9/.9 Had a complete FRQ Running with all parts complete. Used Collegeboard Example to demonstrate full usage
3 0.9/.9 Had a complete FRQ Running with all parts complete. Used a for loop instead of a while loop to search through each comment. Used Collegeboard Example to demonstrate full usage
4 0.9/.9 Had a complete FRQ Running with all parts complete. Used Collegeboard Example to demonstrate full usage

Overall Score 3.6/3.6

PBL Connection Issue

Overall Score: 3.8/3.6

FRQ 1

Utilizing ArrayLists allowed for the emulation of array principles highlighted in the FRQ, showcasing the flexibility and functionality of dynamic arrays. The implementation mirrored the FRQ's focus on iterating over collections of elements, facilitating diverse data handling to the summation and analysis tasks in the FRQ. .

FRQ 2

Used Frame class to demonstrate how some class principles of the 2nd FRQ are incorporated.

FRQ 3

Used progression service to demonstrate 2D Array usage and how 2D Array principles of the 3rd FRQ are incorporated. Explained how stats array is incorporated into the base array with code and words.

FRQ 4

Used JPA to demonstrate example usage of implements and inheritance, which is similarly used in the 4th FRQ.

Explained Everything in a detailed manner in the PBL. Used Code to explain everything for itself. One thing to note is that he would've talked more about some principles like for sparse arrays on removing columns; he probably could have switched FRQs #1 and #3 as the 3rd FRQ example code he used seemed to have some 2D Array Principles incorporated in it and the first FRQ included some arraylist principles, like adding or removing, incorporated. He did solid reflection and explained possible goals he could do in the future. would be better if more specific on the types of FRQs encountered.