Part 1: Encryption/Decryption

In lecture and in our reading we discussed some encryption algorithms including Caesar's and Vingenere's. In this part, you are asked to complete this questionnaire to demonstrate your knowledge of these algorithms.

Note that you have to complete the questionnaire individually.

Part 2: Working with JS Arrays

The purpose of this assignment is to help you improve your skills with JavaScript, specifically you will get more practice with arrays and the for-loop.

You also have to complete this part individually.

Task 0: Set up and preparation

Download a zipped copy of the hw6 starting folder onto your Desktop and open it by double-clicking on it. This folder contains:

  • an html document named assign6.html, that you should not modify, and
  • a JavaScript file assign6JS.js, in which you will add your code.
Open assign6.html in your text editor and examine the code. The goal of this task is to require you to demonstrate your understanding of arrays and the for-loop.

Experiment with this sample video to see how your final program should behave.

Task 1: Managing a collection of Movies

Consider that you have a collection of movies and you would like to have the ability to add new movies on demand, and to have your program suggest a movie of your collection at random. This program will help you to do so.

The program maintains a global variable myMovies that contains an array with a few initial movie names (for simplicity we have named them A, B and C, but you can change them to your taste). Implement each of the functions below. We recommend you work in the order we describe them.

Function randomMovie()

Clicking on the "Recommend" button the program presents the user with a random movie from the collection. This is accomplished by function randomMovie() which first picks a random index between 0 and myMovies.length using the Math.random() method. It then enters the movie that happens to be at that index into text field "randomMovieId" of the Web page.

Function addMovie()

Clicking "Add" the program will add whatever has been entered into the text field "newMovieId" at the end of the myMovie array. This is accomplished by function addMovie() that reads the value stored in the field "newMovieId" into a new variable and, if the field is not empty, adds it as the last element of the myMovies array. If the field is empty, it does nothing. At the end, your code should call listMovies() to refresh the screen to reflect the added movie.

Function listMovies()

Clicking "List" will produce the current list of movies in your collection in a list element of your web page called "moviesId".

To do that you need to write code for function listMovies() that using a for-loop goes through your collection of movies (stored in the myMovies array) and calls function addElementToList() with argument each of the movies in the array. Note that this latter function addElementToList() is provided for you. Examine its code to see that you understand it.

Submission

When you are ready to upload, your folder should contain the assign6.html and the assign6JS.js files.

Important Note

You must upload your hw6 folder to your cs115-assignments folder, which is a subfolder of your public_html one, on the cs server. Your cs115-assignments folder has permissions set so that only you and the instructors/graders can see your work.

Make sure you check the page using the URL once you've uploaded:

http://cs.wellesley.edu/~myname/cs115-assignments/hw6/assign6.html

When you visit the page, because it is protected, you will be prompted for a username and password. You should use your own account name and password for the CS server.

Coding Style

All the usual coding rules apply. See the style rules. Indent properly, use white space to make code more readable, and use comments to explain what effects is being achieved by a rule.

Due Date/Time

Remember that assignments may not be turned in late. They are due at 11:59PM on the due date (check the schedule). Furthermore, remember that this policy means that you should not modify turned in work after the due time has passed, so that when we grade it, it's not time-stamped late.

Honor Code

The Honor Code applies to this course. You are encouraged to discuss assignments with other students, the tutors, and with your instructors. However, you must solve, write up, debug, test and document the assignment on your own. In other words, it is acceptable to talk with other students in English (or any other human language), but not acceptable to use any formal language and especially not HTML, CSS or JavaScript. You should not be looking at other peoples' code or showing them yours. If you worked with others or you have obtained help from any source, you must acknowledge their contribution in writing.

Homework assignments must be your own work. You may not look at solutions from other students, either from the current offering or from past offerings.

Grading

These are the criteria we use to grade the homework:

  • Homework was submitted on the server by the due date. Late submissions receive 0 points.
  • Folders and files have the required names and are uploaded to the proper location.
  • Your files have comments at the top and as necessary interspersed in the code.
  • Your code follows our recommended coding style.
  • You have not modified the original HTML page.
  • The JS code produces correct results for any input.

Help Room

Our tutors in the help room can help you with concrete problems and questions you have about the assignment, thus, go to the room prepared. If you find that you don't know how to start the assignment, you should visit the instructors during their office hours.