-
Notifications
You must be signed in to change notification settings - Fork 5
String Cipher
In this lesson we will be performing string manipulation. This will allow us to change each character of a string into some other character, allowing us to encrypt/decrypt our string.
Sometimes we want to reuse code over multiple places. Although we could copy and paste code blocks, it is not the ideal way to reuse code because it makes our code look more complicated than it really is. Procedures allow us to only use code blocks once and reuse them wherever we want with one block.
We will need to use several blocks to be able to perform certain operations with our text strings.
- Join - allows us to put two text strings and combine them into one. e.g "Te"+"xt" = "Text"
- Starts at - allows us to find where a certain character starts in a text string. For example, if we had the text string "Text", 'T' would be at position 1, 'e' would be at position 2, 'x' would be at position 3, 't' would be at position 4. If we wanted to know the position of "T', we would get the number 1.
We will need a text box, two buttons, a ListView, a Firebase component, and a Clock component.
In the Designer view, under Firebase Properties, use these values for FirebaseURL and ProjectBucket.
FirebaseURL:
https://cpp-ignite.firebaseio.com/
ProjectBucket:
Chat_App
- Create an event handler for the SendButton (SendButton .Click)
- Use the Firebase StoreValue block to store the Text from the MessageBox as the value. For the tag, use the SystemTime from the clock component.
- After the Firebase StoreValue, reset the MessageBox to " " so the user can enter the next message. The " " block can be found under Text.
- Initialize a list to store the messages to an empty list.
- Inside a Firebase DataChanged block, add the message Value to the list variable you initialized in step 1(hover your mouse over 'value' to find the 'get value' block). Note: be sure to add the new messages to the start of the list, not the end (hint: use index 1)
- Set the MessageList to the message variable. This will ensure that the UI actually updates with the new messages.
You should be able to send and receive messages.
- Make your app play a sound every time you send or receive a message.
- Make you app speak the new incoming messages.
- Instead of just showing the message, show the system time, then the message in the format TIME: MESSAGE