Main method + Cipher/Deciphering + proof
Issues: (Look to cipher 2)
This was my original code where I made an array of alphabets that would equal the index number. The issue with this is that certain numbers hold double-digit index’s and the computer reads each individual number. Basically, what this means is that when I decipher for example ‘s’ the value it holds is an 11, but because the computer reads each individual number it will print out as ‘qq’ instead of ‘s’ because it reads it as 1 and 1.
For this project, I decided to make my encryption all about substitution so each alphabetical letter will equal a new one. This code was simple because I just had to watch a video about nested loops and chatAt to understand how to program it. On the flip side, because of the simplicity, it is incredibly easy to decrypt.
What have I learned?
- Nest loops – A loop inside another loop.
- charAt: runs the character in the specified index.
- length() a useful method which tells the computer to count the length of the string
- Empty Strings: Allows you to print what is being looped
- Scanner class: Review of input
- boolean operations: Review on using ‘or’
- if-else statement: Review of if statements
- Hashmaps: Even though I didn’t use this is my code, from this project I’ve understood it. Hashmaps include an array of numbers, and ‘keys’ are used to identify which hashmap in the value to use.
- The difference between Hashmaps and arrays/list in terms of storing data is that Hashmap holds a very specific value which is used. So that when you call the key the hashmap that is being identified is specified.
- Continue: I didn’t use this as well but it basically will execute the condition such as for or do loops. That is why it should be placed within the loop.