Search and Sort

Challenges I encountered included

-How arrayList works

-How to implement skeleton with the code given from the ap syllabus (ap syllabus was in array while the skeleton was in arraylist)

-Understanding how the sort worked

Cipher Summative

  1. What encryption method have you chosen, why did you choose it?

I have chosen the Vigenere Code which is a code based on a specific key phrase that is used to alter all characters inputted. I chose this method because I thought it would be challenging and it would be a viable challenge that I could complete in the time given.  Additionally, this method was highly encouraged by Mrs Mok.

  1. What are the pros and cons of this encryption method?

Pros of this encryption method include that the code is hard to decode when you are given it without the key however once the key is found, the code is super easy to crack. Also coding the encryption is not difficult and can be easily done with the code I wrote or using a simple alphabetical Vigenere Code.

Cons of this encryption method include that the code is easy to decode once a key is found. For example, my decryption method is dependent on a key and without the key, it would be very difficult to decode anything.

  1. Include sketches (e.g. flowchart, pseudocode, diagrams…) you drafted before writing the code.


















In the screencast, show the classes hierarchy of your program

In my code there are three classes. There is a main class: the ImitationGame class which has the main method. The other two classes are Cipher and Decipher which are called on by the user and can be used to cipher a code or decipher a code. THe main class can call up the other classes such as cipher and decipher.

  1. Explain the functions of different methods

Each method is needed to create or procure a different item. For example, if I wanted to create an encoded message, I would need a cipher method to do this. Therefore, different methods are needed to make sure that the functions that we want to produce can be done. As this code is relatively simple, it is easy to forget to split everything into multiple methods, however, once the code gets more sophisticated, to make sure that the code works and doesnt get messy, we must make sure that we use different methods to make everything clear and clean.

  1. Demonstrate how your program encrypt and decrypt a message

In the Vigenere Code, the original text is moved similar to a mod3/ceasar cipher but instead of each character moving the same amount of letters, each character in the original text is moved by a certain number of characters based on the key. As the key is shorter than the actual text, the text is repeated until there are the same number of characters in the original tet and the key. Finally, each character in the original text are altered by the character number of the corresponding key. The decryption key is exactly the same however, it is backwards with each character in the inputted text moving backwards by the character number of the key. Similarly, the key is repeated until it has the same characters as the original text. However the code is not exactly the same as the transition from ASCII to character is very sophisticated and going backwards requires a different calculation.

  1. What have you learned in this project and how does it connect with the topics we covered? (String operations, arrays, loops…)

This project combines everything we have learned from using multiple classes to using the scanner to loops and string operations. I really liked how this project allowed me to demonstrate my knowledge and practice using my skills I have learned and to apply them in a meaningful fun project. By using the cipher and decipher classes separately and using a constructor to call them up in the main method, I was able to practice using multiple classes. The String operations were used when I used the scanner to take what the user inputted into the code and use that as the string to find the cipher/decipher code. Last but not least, I used a for loop with if statements to encrypt and decrypt the messages, as each character had to be checked and by using a for loop, I could check each individual character until all the characters were checked.

Write a vlog post (video log) describing and explaining how you completed the program and all resources (e.g. stackoverflow) you used

Resources used:


Blog 10

import java.util.Scanner;
public class reverseString
public static void main(String[] args) {
Scanner sc = new Scanner(;
System.out.println(“input string”);
StringBuilder input1 = new StringBuilder();
input1 = input1.reverse();
/* byte [] strAsByteArray = n.getBytes();

byte [] result = new byte [strAsByteArray.length];
for (int i = 0; i<strAsByteArray.length; i++)
result[i] =

System.out.println(new String(result)); */


import java.util.Scanner;
public class SequentialSearch {
public static void main(String[] args) {
Scanner sc = new Scanner(;
System.out.println(“How many numbers to sort?”);
int n=sc.nextInt();
int [] array = new int[na];
for (int q=0;q<n;q++) {
//int[] array = {10,3,7,8,2,4,1,6,5,9};
boolean swapped = true;
while (swapped==true) {
for (int i=0;i<n-1;i++) {
if (array[i+1]<array[i]) {
int number=array[i+1];
System.out.println(array[i] + “switched with” + array[i+1]);
for (int j=0;j<n;j++) {
if (j<n-1) {
else {

Blog 9

  1. Write a short paragraph (~100 words) define what an algorithm is.

An algorithm is a more or less compact, general and abstract step by step recipe that describes how to perform a certain task or solve a certain problem. Algorithms are often associated with computer programs but they are not necessarily related to technology. An algorithm could be a formula or way that could allow math to be calculated. Algorithms represent a more difficult way of solving problems.


  1. Choose a recipe algorithm/real-life examples, create:
    i) pseudo code and
    ii) a flow chart (create a flowchart – using the correct flowchart symbols)
    How to make a salad:


  1. Get ingredients such as lettuce and crotons and tomatoes
  2. Get a bowl and cut the lettuce into smaller pieces
  3. Cut tomatoes into halves and pour in bowl
  4. Add mustard, pepper and olive oil
  5. Mix the bowl
  6. Add the crotons at the end
  7. Sprinkle the cheese

(Refer to fig. 7-2) of the scenario you have chosen. Submit the complete work on Schoology in pdf format.

Blog 8

During this class, we reviewed how to use instances of objects when running a program and how to write a program with multiple classes. We did this through two challenges.  We had the time to complete the first one by hand and computer. as it was easier.

Here is the code: (All it did was find the page number and based on that find the current page)

The second challenge was more sophisticated. However it was just like my adventure game (like exactly with different words). And since I didn’t have time and I already knew how to do it. I did parts of the code on my computer. It worked like the adventure game blog post before described, by finding the level of the game and using setters and getters to find the right level based on user input.

Here is the code:


Blog 7

Here is the driver and the other class that will create a user with a game and a number or just a game. It worked just as the one that Ms. Mok taught in class.  It uses getters and setters to store the values and also print them. Objects are used to take the elements from another class.




Adventure Game

In this game, I made the main class and used setters and getters to direct the user to each level or each stage.  For example, in the beginning, I used a boolean so that if the user put yes or no, it would become a boolean of true or false which would either start the game or quit the game. Next, I used integers instead of the boolean and was able to make it so that it would change the level based on the integer returned.  This adventure game was able to use two classes, create objects and use it to create function.


Code is also on github:

Here is the result:


Here is the flowchart

Blog Post 5

During this class I worked on two codes:

1st One: Learning to use a method so that the main doesn’t have to contain any code but call up the code from the other methods.  The main thing I couldn’t figure out was why there needed to be an open empty Hero method. Later I figured out that there needed to be an empty method to store the data recieved from the scanner.  Next in the main method, it would be able to call up the stored data and print it.

2nd One: Learning to make a password checker in which I used my knowledge of loops (while, for) and conditional (if, else) and the scanner. This was relatively simple but one problem was that the code wouldn’t always work (it would print false with right password or print right with wrong password on third try) and I am still working on fixing that.

Blog Post 4

Her are two programs I wrote that are using multiple classes and objects to display a code.  In the first one, the main code has the settings for the superhero, and in the hero code, I was able to allow the user to input the hero specifications which would then be assorted into the user information and printed.  The other program is a calculator.  In the main program, it prints out all the dialogue and the calculation is an object which is linked to the other class called operations which does all the operations such as adding, subtracting multiplying and dividng.  Initially, I had a problem as the code wouldnt work and then I learned that I could fix this simply by adding one line: Operation Answer = new Operation (a,b).  This code would take the a and b from the user, and transfer it to this other class that would calculate the data.  Later on by printing answer.addition in which addition was the code for adding the numbers in the operation code, it recalled the answer  and printed it.  Although not really necessary for this calculator, using two classes help to organize code so that there would be one main which could recall all the other functions in other classes.