+ Symbolic Encryption + String class // Comparing String objects, - - PowerPoint PPT Presentation

symbolic encryption string class comparing string objects
SMART_READER_LITE
LIVE PREVIEW

+ Symbolic Encryption + String class // Comparing String objects, - - PowerPoint PPT Presentation

+ Symbolic Encryption + String class // Comparing String objects, see reference below. String p = "potato"; if (p == "potato") { println("p == potato, yep."); // This will not print } // The correct way to


slide-1
SLIDE 1

+

Symbolic Encryption

slide-2
SLIDE 2

+String class

// Comparing String objects, see reference below. String p = "potato"; if (p == "potato") { println("p == potato, yep."); // This will not print } // The correct way to compare two Strings if (p.equals("potato")) { println("Yes, the contents of p and potato are the same."); } // Use a backslash to include quotes in a String String quoted = "This one has \"quotes\""; println(quoted); // This one has "quotes"

slide-3
SLIDE 3

+String

A String is an ordered group of characters. A String literal is an ordered group of characters enclosed in quotes: "This is a string literal" "so is this" "and this" "also" "hello" "12345" ":) (:"

slide-4
SLIDE 4

+Initialize a String

n String x = "test"; n There are other ways, but we'll just focus on the above for

now.

slide-5
SLIDE 5

+String methods

n charAt()

Returns the character at the specified index

n equals()

Compares a string to a specified object

n indexOf()

Returns the index value of the first occurrence of a substring within the input string

n length()

Returns the number of characters in the input string

n substring()

Returns a new string that is part of the input string

n toLowerCase()

Converts all the characters to lower case

n toUpperCase()

Converts all the characters to upper case

slide-6
SLIDE 6

+Calling methods on a String

n String x = "test"; n char first = x.charAt(0); n int one = x.indexOf('e'); n int len = x.length(); n String sub = x.substring(0,2);

slide-7
SLIDE 7

+'modifying' a string

n String a = "hello"; n String b = "world"; n String e = a + ", " + b; n Strings cannot be modified, but you can put them together

with the "+" sign. This is called concatenation.

n e += "!"; n println(e);

slide-8
SLIDE 8

+What is symbolic encryption?

slide-9
SLIDE 9

+Example: Pigpen cypher

slide-10
SLIDE 10

+Example: Templar cypher

slide-11
SLIDE 11

+Exercise

n Download typingInteraction.pde n Modify it to use a shape drawing function that can create a

different symbol for each character from space, ' ', to tilde, '~'