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
Features
- Sponsored By coding4Kidz this trimester
- Partners with Chris Diriou (My scrum Partner)
- P2-Weasels: (Aman, Arnav, Chris, and Raquib)
- Deep Interest for Computer Science
- included here is my commits for this trimester so far
- Preparing for AP Test this May
- Lakers Fan
- responsive Wesbite!
Java FRQ’s (Somthin Cool)
FRQ2 Using Objects
- We created Objects and Initialized them in this FRQ. Difficulty level = easy
```Java
class frq2 {
// creating class lightsequence
// create variable called string sequence
public static void main(String[] args) {
class LightSequence {
String sequence;
// 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
- This was a good practice for me to write classes
-This Frq was about writing classes and through trimesters one and two, Mr. Mortensen has given a lot of practice with writing classes and the fundamentals of how to write a class in Java
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
- In this Frq, it was mainly focused on taking a string of the words and finding the words that end with -ing. Overall, this was one of the easier frq’s if not the easiest FRQ. Since we are creating an array list and using a for loop to check through each word to see if it ends with ing, it was very easy to code. Overall, adding the system. scanner and importing that class helped create the user input needed for this FRQ! This was a fun problem to solve and it was good practice for the AP Test!
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
- this is a prime example of how to use 2d arrays
- defining the p#
- inserting into 2d arrays [][]
- This is one of the harder frq’s as it was hard to grasp the idea of 2-D arrays and how they work
```Java
public static void main(String[] args) {
frq8 p1 = new frq8(“corn”, 20);
frq8 p2 = new frq8(“corn”, 30);
frq8 p3 = new frq8(“peas”, 10);
frq8 p4 = new frq8(“peas”, 30);
frq8 p5 = new frq8(“corn”, 40);
frq8 p6 = new frq8(“corn”, 62);
frq8 p7 = new frq8(“wheat”, 10);
frq8 p8 = new frq8(“corn”, 50);
frq8 p9 = new frq8(“rice”, 30);
frq8 p10 = new frq8(“corn”, 55);
frq8 p11 = new frq8(“corn”, 30);
frq8 p12 = new frq8(“peas”, 30);
frq8[][] plots = { { p1, p2, p3 }, { p4, p5, p6 }, { p7, p8, p9 }, { p10, p11, p12 } };
## 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
- gcf method returns the greatest common factor
- This is a math program in which it takes the user input and takes 2 numbers from the user and outputs the GCF of both numbers. Honestly a cool function. W moment in the chat guys. #GuapOnTop
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