Trimester 3 Data Structures

About

Raquib Alam

Welcome to Raquib Alam’s Trimester 3 Github Pages! This is where you will find all my links, tnagibles, code and notes that I have done this trimester! This is made possible by using Jekyll Github Pages to display all my content this trimetser

screenshot

screenshot

screenshot

Features

Java FRQ’s (Somthin Cool)


FRQ2 Using Objects

// calling this.sequence to the light sequence class // setting this.sequence = sequence public LightSequence(String sequence) { this.sequence = sequence; }

// creating a new class called insertSegment whith a string and integer parameters public String insertSegment(String segment, int ind) { StringBuilder sb = new StringBuilder(segment); sb.insert(ind, segment); return sb.toString(); }

// this is the main class // this is where the code is being ran and called public void changeSequence(String sequence) { this.sequence = sequence; }

// this code prints the sequence public void display() { System.out.println(sequence); }

}

## FRQ3 Boolean Expressions and if Statements
- This was our user input FRQ
-We created this through a hackathon that was presented to us by our teacher
- We were able to complete the first two challenges of the FRQ, in which we has to manipulate the code to create a box in the specific areas
-When it came to the user input part, it was very hard to do at first, but through the help of our classmates and peers, we were able to finish it. 
- Luckily we had Morts code

      ```Java   // starting coordinates
        const x = width*.5 ;
        const y = height*.5 - unit*4;
        // length of sides is 4 units
        const l = unit*4;

        // draw a square
        ctx.beginPath();
        ctx.moveTo(x+(returnNumber()), y+(returnNumber2()));
        ctx.lineTo(x, y+l);
        ctx.lineTo(x+l, y+l);
        ctx.lineTo(x+l, y);
        ctx.lineTo(x, y);
        ctx.stroke(); ```

## FRQ4 Iteration
- This was an FRQ for Loops
- We were trying to iterate through a class
- Part 2 was harder
- My team helped me this that part
- For me, this was one of the harder FRQ's to accomplish as the key concept of the unit was hard to grasp and the question that was asked was very confusing to follow for me. 

```Java
        while (round <= maxRounds && p1coins >= 3 && p2coins >= 3) {
            p1spend = getPlayer1Move(); // no parameter for this one
            p2spend = getPlayer2Move(round); // round number included
            p1coins -= p1spend; // coins spent in round
            p2coins -= p2spend; // coins spent in round
            System.out.println("Player 1 has:" + p1coins);
            System.out.println("Player 2 has:" + p2coins);
            if (p2spend == p1spend)
                p2coins++;
            else if (Math.abs(p2spend - p1spend) == 1) // difference is 1
                p2coins++;
            else
                p1coins += 2;
            round++; // increment round
            System.out.println("This is round" + round);
        }
        /** determining the winner*/
        if (p1coins == p2coins)
            System.out.println("Tied");
        else if (p1coins > p2coins)
            System.out.println("Player 1 Wins");
        else
            System.out.println("Player 2 Wins");
    }### 

FRQ5 Writing Classes

public class frq5 {

//String hostName;
//String address;
//String nameString;
//int age;



public String getHostName(String hostName){
	System.out.println(hostName);
	return hostName;
}

public String getAddress(String address) { 
	System.out.println(address); 
	return address;
}

FRQ6 Array

Java list.add(userWord); list.add(userWord2); list.add("Hellow"); list.add("LeBron"); list.add("Talking"); list.add("Walking"); list.add("Crying"); list.add("tech-talking");

## FRQ7 ArrayList
- This was about adding to an array list
- we specify the array values as strings
- this makes it so we are retrieving letters and not numbers
- then we do the additional feature which adds test 1-3 to the array list

```Java
  public static void main(String[] args){
        ArrayList<String> possibleNames = new ArrayList<String>();
        possibleNames.add("test");
        possibleNames.add("test1");
        possibleNames.add("test2");
        possibleNames.add("test3");

        ArrayList<String> usedNames = new ArrayList<String>();
        usedNames.add("test2");

FRQ8 2D Array

## FRQ9
- Class named PictureBoo
- using extend feature to pull data from a different class called book
- then uses the super. feature to pull data from class Book which is in another file
- this prints the sentence the college board wanted

```Java
public class PictureBook extends Book {
	private String illustrator;
	
	public PictureBook(String t, String a, String i) {
		super(t, a);
		illustrator = i;
	}

	public String printBookInfo() {
		return super.printBookInfo() + " and illustrated by " + illustrator;
	}

	public static void main(String[] args) {
		Book book1 = new Book("Frankenstein", "Mary Shelley");
		Book book2 = new PictureBook("The Wonderful Wizard of Oz", "L. Frank Baum", "W.W. Denslow");
		System.out.println(book1.printBookInfo());
		System.out.println(book2.printBookInfo());
	}
}

FRQ10

    public static String reduceFraction(int numerator, int denominator){
        String returnValue = "";
        if(numerator % denominator == 0){
            Integer i = numerator / denominator;
            returnValue = i.toString();
            System.out.println(returnValue);
        }
        else{
            frq10 temp = new frq10();
            int gcf = temp.gcf(numerator, denominator);
            int num = numerator/gcf;
            int den = denominator/gcf;
            returnValue = num + "/" + den;
            System.out.println(returnValue);
        }

        return returnValue;

    }

License

public domain