2D Array HKIS Logo

public class image
{
public static void main(String []args) {
int[][] hkisLogo= ((** THE HKIS LOGO THAT MR LIN SENT US **))
String[][] replace = new String[hkisLogo.length][hkisLogo[0].length];

for (int row = 0; row < hkisLogo.length; row++){ // goes over every row and changes the value to whatever I want to set it to, loop continues till it reaches every row.
for (int col = 0; col < hkisLogo[row].length; col++){ //goes over every column and changes the specific value to whatever I want it to be
if(hkisLogo[row][col] == 255){ // tells the computer that if it sees 255 in the 2d array, then it should change the value to 00.
replace[row][col] = “00”;
}
else if (hkisLogo[row][col] == 0){ // tells the computer that if it sees a 0 in the 2d array then it should change it to a space
replace[row][col] = ” “;
}
System.out.print(replace[row][col]); // tells the computer to print the 2d array with the altered values from the conditional statements above

}
System.out.println(); // prints the array
}


In my code, I first wrote a series of two for loops in order to convert and identify values in each and every single one of the rows and columns in the ascii picture that Mr. Lin sent us. After that, I wrote a conditional statements that tells the computer to change every 255 value to a 00, and every 0 to a ‘space.’ This essentially alters the photo to look a little bit different. Finally, I wrote a print statement to print my new and improved picture.

APCS A: D(Encryption) Summative

At first when approaching this summative, I was really confused at where to start. I originally had an idea to create an array which would be paralleled onto a new array, which would be made out of different letters and symbols. However, after a class period where we review how to utilise ASCII in java, I chose a slightly easier pathway.

First, both my Encrypt and Decrypt class contained one constructor and four methods. In each class, the only constructor defined the instance variable of word and text in the encrypt and decrypt classes respectively.

The first of the four methods, named getLength, simply identified how many characters existed a word that was specified within the main method class. I was able to utilise this method in my final encrypt method to set a a parameter for the loop, ending where there were only so many characters in whatever string input that the user wanted to use.

The second of the four methods, the returnACharacter method, functioned to return each of the characters that are present in the word, then spacing them out. This was utilised in my final method to make each character unique before I altered them into different forms, as you’re about to see. This method also used the getLength method in order to see how many characters a word had, thus only carrying out a function on the letters in the word and no more.

The third of the four methods was the returnASCII method. This method took characters and returned their ASCII value instead of their string value, thus assigning each character to a numeric value that we could use to further encrypt our code.

Finally, our fourth of the four methods was used to actually wrap everything together. Here, I set up two variables, x, which represented the getLength method, letting me set a parameter on the function that I was planning to carry out. The second variable, counter, helping me make increments on the progress of the reaction, where each increment had a function that was carried out on that certain letter. Finally, I had a final variable which was just an empty string which I later combined with an integer in order to turn it back into a string. After setting up these variables, I created a while loop, setting the parameter to up to as many characters there are in the word. Here, I created an integer-based ASCII variable, which first took the character at a certain place depending on the counter, then returned it’s respective ASCII value. Here is where the two classes, Encrypt and Decrypt, were different. Encrypt had a +1 after the returnASCII and returnACharacter, this ensured that the letters were scrambled to go from ‘abc’ to ‘bcd,’ which actually resulted in a different character, which is where the encryption was happening. Decrypt did the opposite, returning a word to it’s original meaning by being able to go from ‘bcd’ back to ‘abc.’ After this ASCII variable was declared, I set a new variable which changed the numeric-integer value that the ASCII variable contained into a character, which would be turning the numeric value back into english alphabetic letters. Then, a simple line of code adding together each of the characters in order to build a word back up using characters, which would be concatenated into words.

When writing this code, I didn’t actually consult any online sources or something like stack overflow. Instead, I took the work that we did in class on Tuesday, the 21st of November, and added a few changes to it. Things that really aided me in this project included the creation of flowcharts which helped me understand what I was trying to accomplish, and the steps that it took for me to get there. From previous classes, I was able to understand that in order to turn the integer value back into a string, I had to concatenate it with an empty string, as indicated in my code. By doing this, I was able to create the flow of how my code worked.

Finally, after all pulling together, I was able to create a program that took a string that could take in all words and letters, and changed it into something different, an encrypted word! In a similar way, my program is also able to return an encrypted word into it’s generic english meaning, or at least back to whatever you were trying to hide…

Proof that it works:

Sorry about the quality of the second picture, blueJ doesn’t fold into new lines and I wanted to show off all of the symbols. You can click on it to enlarge it.

APCS: Creating a Basic File and Class on Terminal

Today we looked over creating a simple file and class on Terminal.

Through terminal, we were able to look through the difference functions that we could perform on the terminal bash.

The first step to the task of creating a file that we could carry out included creating a directory on our desktop, to do this, we use the syntax: ‘ cd desktop (finding the directory for the desktop) –> mkdir HelloWorld.java (creating the folder which will include the java file –> nano HelloWorld.java (opening the editing directory for the file)’ 

This opens up a directory on terminal that looks different (^^^as inserted above^^^)

Within this tab, we inserted the syntax:

public class HelloWorld {
public static void main( String[] args ) {
System.out.println( “Hello World!” );
System.exit( 0 ); //success
}
}

This, followed by:

‘ javac HelloWorld.java ‘

and

‘ less HelloWorld.java ‘

summons a window that shows you what it looks like on a window without code : )

 

 

I2P: Design thinking Questionnaire – Final Project

Today in class, we ventured down to the middle school and asked Mr. Coleman a few questions about the P.E department in the Middle School and how we could make it better for everyone down there. I noted down his problems, and we brainstormed to find the best project that we could effectively work on and finish within the time parameters given.

We ended up settling on making an automatic mile counter which didn’t require the work of peers to time yourself or for inaccurate measurement of splits.

For the rest of the class period, we worked on whiteboards in the project room and wrote down some of the code that we need, setting all of the variables required.

WhatsApp Image 2016-12-14 at 10.31.44 AM

Although the picture is a bit unclear, it shows the map of the field and where our checkpoints will be set with the variable markers that adjust the timer.

I2P: Explore Makey Makey & Balance Board Challenge

Screen Shot 2016-12-05 at 4.02.42 PM

This is a photo that shows my code. For the majority of the class, my partner and I were problem solving on his computer. However, half-way through the class we experimented with making a keyboard, of which I do not have access to.

Basically, what went well in our code was being able to functionally set up a game involving the balance board even though it was quite primitive and had to be reset manually by the player. However, it was still a game and counted the amount of time that we spent on the board.

What didn’t go so well was finding out how to hook the code up to the balancing board, of which my partner and I spent a lot of time on. Because we were a bit lost as to how to properly connect it, we ended up using a variety of methods that didn’t really work (connecting clips to each other). But in the end, we were able to hook it up to create a function game board.

Next time, we should try to get straight to the point instead of searching for shortcuts in the code or connection via the alligator clips.

 

 

I2P Summative: ‘The Quiz’ Final Post

29112016073854-0001

Attached above are two pictures which are of my mind map and pseudo code. Together, they outline what the direct aim of my code is, along with how to choose to look to satisfy that objective within the code through simply written english language steps. (In order for the picture to work you have to open the link in a separate tab and click on the link within the text area)

Below is a video of me explaining the code behind my actual quiz, it contains a rundown of the whole code, which includes annotations for separate things if I happened not to explain it.

In the process of working on my code, I referred to just three websites along with our teacher, Ms. Mok, and her knowledge to help me overcome my challenges and properly create my code, making sure that it functions properly.

-http://www.python-course.eu/python3_global_vs_local_variables.php

I used this website to research along with the advice that Ms. Mok gave me on global functions. Because we were just given a small tutorial in class on how to transfer variables across functions, I was a little bit unclear on what I was meant to do in order for it to work correctly. Therefore, I went on this website to teach myself how to use the global functions, which ended up working quite effectively.

http://www.hashbangcode.com/blog/stopping-code-execution-python

The link above helped me look for what to use in order to loop my function from the end back to the start. However, once I realised that I can just use a function to loop the whole thing in order for it to work, I didn’t end up finding a need in this.

http://stackoverflow.com/questions/14907067/how-do-i-restart-a-program-based-on-user-input

I used this link to make sure that I was using the correct syntax to close my code. Because I wanted to include multiple points of ending, all out of a loop, I was out of options for the use of syntax that we learned in class such as ‘break,’ and instead resorted to searching up and using the syntax, ‘quit().’

Inserted below is a table which discusses the different problems that I faced, and how I overcame all of them except for one due to a challenge/time constraint over the project as a whole.

Item: Test Outcome: Fixed: Date: Who:
Using Lists Pass Yes // I had to make sure that it would properly
project across my code when repeated. I didn’t know
if I had to make it global but I wanted to make sure to
include it in my overall quiz function.
Nov 21 AA
Confirmation Fail No // In the first class I had attempted to create a
way to confirm the choice of each answer, but then I
realised that it was going to take too long, and that I
didn’t know how to properly create the confirmation
loop itself.
Nov 21 AA
Input Pass Yes // It wasn’t originally working because I had
forget to input the variable the first time in the
function which didn’t let the second half of it work
properly.
Nov 21 AA
Function / Def. Pass Yes // I had originally planned to manually loop the
whole thing but then I realised that it would take way
too long to actually manually loop things around in
circles and that I’d never actually be done because
it’s an infinite loop. Then Ms. Mok taught me how to
create functions properly which I ended up doing.
Nov 28 AA/MOK
While Pass Yes // Was working when I just used basic while
I just used basic while functions. However, when I
attempted to use harder loops like when I tried to
manually loop my code, I ran into a lot of problems.
Nov 21 AA
Ending the Code Pass Yes // I wasn’t using a proper end to the code in
some parts of the code which just led to the code
repeating itself in a messy way that didn’t ever end
the code itself. Ended up searching up and learning
to use the ‘quit()’ syntax instead of ‘break’.
Nov 28 SS
Defining variables
inside the function
Pass Yes // After I looped my code using the functions, I
had no idea as to how I was meant to define the
variables properly inside the code itself. Therefor,
when I asked Ms. Mok for help, she directed me to
the proper use of the ‘global’ syntax, which is what I
used to correctly be able to score the amount of
questions incorrect per quiz.
Nov 28 MOK

 

I2P Summative: ‘The Quiz’ Version 1

This class I first wrote out a pseudo code and flowchart for the majority of the class, choosing which routes I could take and how to get from place to place in my quiz.

When I was done, I got to work on some minor coding. I first created a small background content for the quiz, then a list for the types of quizzes that the player could choose to play from.

After this, I decided to just add a small basic script of which the quiz would simply follow throughout the rest of the quiz in order to provide the user with the desired quiz and the questions that they offer.

I2P: Adventure Game

 

I2P Formative Recording

Attached above is a video of Sid and I summarising the code which we wrote, showing examples of all of the different things that we’ve learned in class so far.

 

Screen Shot 2016-11-15 at 3.02.43 PM

This is an image that shows how we used a function to resemble a picture made out of symbols which we used across the code as a universal signal for game over.

————————————————————————————————————————

Below is an image that shows the first part of out code, which includes a list, the use of elif, if, and how inputs work. We produced a summary outlined in the annotations in the picture itself.

 

 

Screen Shot 2016-11-15 at 3.03.07 PM

In this image, we showed the use of a variable in the hunger, which changed depending on what the player inputted into the input section. We also demonstrated how to summon the backpack list which we created at the start.

————————————————————————————————————————

Screen Shot 2016-11-15 at 3.03.14 PM

This image shows how after demonstrating the techniques and concepts learned in class, we were able to just continue the storyline of the code without much trouble. Note, the ‘endgame()’ summons the game over sign that we produced in the function at the top of the code.

——-

The rest of our code is just storyline, lacking any other concepts beside print and input functions.

Overall, we didn’t have too much trouble creating the code, only problem was synchronising all of the functions and lists throughout the code, by making sure to include a ‘()’ or if we were meant to use square brackets instead.

Attached below are our mind maps and pseudo code:

20161115_15051620161115_150509

20161115_150524

 

 

 

 

Python Lesson 4: Reflection

Screen Shot 2016-10-26 at 8.48.21 PM Screen Shot 2016-10-26 at 8.45.36 PM

 

Today in class we went over the concepts of If, Elif and While:

If: Sets the condition for a response depending on what the player or user of the code has provided

Elif: Although not shown in my code, Elif is how to write therefor in the code, meaning that it provides a response based on the response of the If command.

While: Creates a loop to set a response for an input of an answer that was not of the given answers.

 

Loops: When would you use a ‘while’ loop and when is it appropriate to use a ‘For i in ___’ loop? explain in detail:

It is a lot easier to use the while loop because instead of infinitely looping, it loops until you get the correct answer, where it will stop looping. The ‘for’ loop will keep repeating for a set amount of times which can’t be affected by the user who can correct the mistake.

 

Python Lesson 2

Screen Shot 2016-10-06 at 9.08.01 AM

 

Today in programming, I had arrived a little bit late due to a bus problem on the way to school. In class, we made two things, first, I learned what slice was, and how it works. Later on, we experimented and played with creating a guessing game. To create the code, we were taught to create a pseudo code, which means that we were essentially writing the code, but in english words, explaining what it does. We wrote down how we would make the guessing game, then wrote the code based on our steps.

To create the code, we used the ‘if’, ‘while,’ ‘print’, and our knowledge of variables.