Skip to content

String Cipher

Anthony Graca edited this page Oct 28, 2016 · 13 revisions

Overview

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.

New Concepts

Procedures:

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.

Procedure

Clock

We will be using the SystemTime block from the Clock component. This will allow us to get a somewhat unique and in order key for our key-value Firebase database.

VoiceRecognizer

Let's Get Started!

User Interface Designer:

We will need a text box, two buttons, a ListView, a Firebase component, and a Clock component. DesignerView

Firebase Properties

In the Designer view, under Firebase Properties, use these values for FirebaseURL and ProjectBucket.

FirebaseURL: https://cpp-ignite.firebaseio.com/

ProjectBucket: Chat_App

FirebaseProperties

Logic :

SendButton Setup

  1. Create an event handler for the SendButton (SendButton .Click)
  2. 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.
  3. After the Firebase StoreValue, reset the MessageBox to " " so the user can enter the next message. The " " block can be found under Text.

MessagesList Setup

  1. Initialize a list to store the messages to an empty list.
  2. 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) ListInsert
  3. Set the MessageList to the message variable. This will ensure that the UI actually updates with the new messages.

TEST

You should be able to send and receive messages.

Stretch Goals:

  1. Make your app play a sound every time you send or receive a message.
  2. Make you app speak the new incoming messages.
  3. Instead of just showing the message, show the system time, then the message in the format TIME: MESSAGE

External References:

Clone this wiki locally