Welcome to your second practical project. For this project, you will be given a set of specifications, and you will build the entire (mini) application from scratch. These practicals are designed to build you up to what you will see in other courses, and more importantly, have you focus more on the design of your programs. As such, there won’t be step-by-step instructions, so it is important to start early, take it in small parts, and build up to the final product.
In addition to writing the code, you will be learning to use an Integrated Development Environment (IDE), and in particular for this class, you will be using IntelliJ. While you are technically free to use other IDEs, if you have issues with other environments, the TAs will not be able to support you. See setup instructions below.
Scenario
You have been hired to build a simple console/terminal based program that either encrypts a String using a Caesar Cipher, or that performs a Lossy Compression. You will also be given the challenge activity to write a Run-Length Encoder which is a lossless data compression scheme.
While this program, the Encrypted Message App is relatively simple, it is actually at the heart of a lot of internet/networking traffic. Any traffic on the internet goes through other computers, and even the neighbor sitting next to you has the ability to analyze the packets of information you are sending. Encrypting such information becomes critical for a security layer. While most encryption is more complicated than this class, a cipher is a way to start thinking about it. Furthermore, sending data online is expensive, and the more we can compress that data the faster and cheaper it is to send it. All modern websites compress the data before it arrives at your browser, and then it is uncompressed. Some compression, you loose some original information, but you can still understand it (JPEG images). Other compression algorithms the information is fully reproducible (Lossless), but at a greater expense. The Encrypted Message App helps you explore these concepts.
Requirements
The App will take in client input from the commandline, simply asking for a message and then a scheme to follow. The application will manipulate the message, and simply print out the result. The program will continue to loop until someone types exit for the message.
Here are some examples of the program running:
=== Practical 2 ===
Enter Message: the answer to the ultimate question of life, the universe, and everything.
Cipher,Encode,Compress: compress
th answr t th ultmt qstn of lf, th unvrs, and evrythng.
Enter Message: Ada is cool
Cipher,Encode,Compress: cipher:2
Cfc"ku"eqqn
Enter Message: AAAAbbbccccdddeeee
Cipher,Encode,Compress: encode
4A3b4c3d4e
Enter Message: exit
Have fun!
Program Specifications:
- The options for manipulation are:
- cipher:N - where N is the amount of caesar cipher shift
- encode - (OPTIONAL) performs run-length encoding
- compress - removes all vowels from words, unless the vowel starts a word.
- The message can be anything, but once
exit
(lowercase) is typed, the program ends. - The program will print the message to the screen with the modification and repeat.
Coding Specifications
For grading purposes, we are asking you to follow this format:
- Three classes will be made and submitted
At the minimum you will implement the public methods as listed in each of the javadocs, and you should implement the field variables as we did. Note that they are all ```final`` for this assignment. Details are given in the method description of how they are supposed to work. Most of your work will be in StringManipulator.java.
You are free to add additional methods to help you out! Furthermore, we will not be grading your splashScreen or exitScreen, but we still encourage you to have fun with them.
Last but not least, you must write tests for StringManipulator.java in a separate main method (see javadoc for details). You can run this separate main method in intelliJ by clicking the green arrow next to it. We will check to make sure you wrote the tests. It is also common practice writing tests for each of your classes you write to ensure they are correct before moving on. This skill is essential for larger programs, and eventually your final summative project!
Where to Start?
Here are some hints on how to start
- Write down on paper what you want to do!
- do you understand the specifications? If not, ask on MS Teams!
- Draw out the program flow. Can you picture how the program will work?
The picture doesn’t have to be clear, but seeing a picture can help you see how classes interact.
- Look at the problems, divide and conquer.
- What do you know how to do?
- Are you confident on the user input part and writing to console? Start in EncryptedMessageApp.
- Are you more interested in tackling the cipher or compress? Start in StringManipulator
- DON’T write everything at once.
- Make sure to write a few lines at a time, compile, repeat - really
- Try to figure out ways to test. When we started, we would just run the program without any of it working, but it was displaying. We then wrote ‘empty’ methods often returning a String that was just the method name, to make sure our if statement was calling the correct method.
The hardest part of this assignment is starting and setup. Make sure to do that right away, and get something showing up on your screen.
Finishing up
To turn in your assignment, click through the Practical 2 link on canvas, upload your files to the project and click submit for grading. Note you can do this more than once, as there is probably a test case you all forgot.
Please complete the reflection in canvas. Something to consider in your reflection, this application is stateless. That means whenever the application closes all information is lost - including the messages. How would you keep state between times when the application runs? If you think about it, a word file is storing the ‘state’ of what you are typing. What if you want to keep the messages for storing them later?
Going Further
If you enjoyed this application, you really will want to look at the Networking and Cyber Security Concentration for computer science (netsec). You can also learn more about the field. Additionally, what happens if you scale the program up to 1,000,000 clients or more? Computing Systems is critical to understanding how we scale applications for large audiences, among other areas.
Setting Up Your IDE - IntelliJ
Applying for a free version of IntelliJ Ultimate with JetBrains
Apply for a free version of IntelliJ Ultimate here. Fill out the application with your university email address. Be sure to check your email and accept the License Agreement. Then log in or create a Jet Brains account to link your free license.
Installing the JetBrains Toolbox App
The JetBrains Toolbox App is a hub for all JetBrains IDEs and will keep your IDE up to date. You can download it from here. Make sure to select the correct version for your operating system. Once the Toolbox is installed, open it and install IntelliJ IDEA Ultimate.
Creating your first Project in IntelliJ
- Open IntelliJ and select Do not import settings.
-
Log in with your JetBrains account. At the top left select File > New > Project… or simply New Project from the start up menu.
-
In the pop up under Project SDK: select Download JDK… (see picture bellow)
-
Make sure to select version 15 and Oracle OpenJDK. Leave location as is and click Download. (see picture bellow)
-
Select Next twice, then you will be asked to input a title for your Project. (see picture bellow)
-
Select Finish. You may be asked if you want to open the new project in the current window or a new one. Select This Window. Congratulations! You now have your first Java Project. Click Project on the left hand side to expand your project directory.
Running Your Program
There are multiple ways of running a program in IntelliJ. First, select the Main file in your project directory. The symbol should have a tiny green arrow next to it. Then select the green arrow to the left of “public class Main”. Select Run Main.main() and your program should run.
Another way is by selecting the green arrow at the top right of the window.
A console window should pop up if you have run your code successfully. To stop the program simply select the red square in the top right or bottom left.