HOMEWORK
PIC 10C, Winter 2004
PROGRAMMING PROJECTS:
-
1. Due date: 01/16/2004, by 12:30 pm.
- Required File Names:
hw1.cpp
.
- The exercise is a modified version of an exercise from
"The C Programming Language", 2nd Ed.
Write a program to remove all comments from a C++ program. Don't
forget to handle quoted strings and character constants properly.
C++ comments do not nest.
- Make sure that you submit your header
in the required format, and that you follow all the instructions
listed below on this page.
-
2. Due date: 01/23/2004, by 12:30 pm.
- Required File Names:
hw2.h, hw2.cpp
.
- The exercise is based on Example 3
which presents a bare-bones implementation of a Linked List data
structure with a corresponding driver program:
Your task is to reimplement this example using traditional technique
of object-oriented programming - type polymorphism (based on
abstract classes and virtual functions) - discussed during the first
week of the course. In particular, your reimplementation should
eliminate all void pointers and function pointers, introducing
abstract classes (interfaces) and pure virtual functions instead.
(In other words, your setup should resemble that of
Example 1.) You are also
responsible for rewriting the driver program (which would
demonstrate actual use of your Linked List implementation) accordingly.
- Make sure that you submit your header
in the required format, and that you follow all the instructions
listed below on this page.
-
3. Due date: 02/09/2004, by 1:00 pm.
- Required File Names:
hw3.h, hw3.cpp
.
- The exercise is based on Example 3
which presents a bare-bones implementation of a Linked List data
structure with a corresponding driver program:
Your task is to reimplement the example once again, but this time
you are asked to use technique of generic programming -
parametric polymorphism (based on C++ templates) - discussed
during the third week of the course.
In particular, your reimplementation should eliminate all void
pointers and function pointers, introducing appropriate template
classes and template functions instead. You are also
responsible for rewriting the driver program (which would
demonstrate actual use of your Linked List implementation) accordingly.
- Make sure that you submit your header
in the required format, and that you follow all the instructions
listed below on this page.
-
4. Due date: 03/12/2004, by 1:00 pm.
- Required File Names:
hw4.h, hw4.cpp
.
- Your task is to create an application that would allow a user to
encrypt and to decrypt messages using RSA public-key cryptography.
The application should contain following classes:
BigInteger
that would implement multiple-precision
arithmetic on integers of unlimited size;
KeyPairGenerator
that would generate a public/private
pair of keys;
RSACrypto
that would implement RSA
encryption/decryption algorithms proper following the guidelines
outlined in Example 4;
RSA
that would provide a convenient front-end for
the entire application;
- Any other classes that might be appropriate according to your
design. For example, a separate class
RSAKey
to
store a key (either public, or private) might be useful.
You should also provide a main()
method to test your
application by creating an instance of RSA
and calling
its various methods. The following usage should be supported:
hw4 -genkey publicKeyFile privateKeyFile
that would generate a new pair of public/private keys and
store them in corresponding files in plain text;
hw4 -encrypt keyFile plaintextFile encryptedFile
that would encrypt plaintextFile
using the key
from keyFile
and store result in
encryptedFile
;
hw4 -decrypt keyFile encryptedFile decryptedFile
that would decrypt encryptedFile
using the key
from keyFile
and store result in
decryptedFile
.
Implementation remarks:
- Please use a fixed block size of 64 bits.
- Your
BigInteger
class should implement all
standard arithmetic operations available for type
int
. Whether you use for this operator overloading
or just methods is up to you. You should use STL
vector
container as internal storage to implement
your BigInteger
. The idea is very simple: using
vector
you can implement big integers as arrays
of ordinary integers. Think about "base 1000" representation
of an integer: each node in a vector
will hold an
integer less than 1000. The number represented is the
concatenation of the numbers in the nodes. For example, if there
are four nodes with the four integers 23, 7, 999, and 0, then this
represents the number 23,007,999,000. Note that the number in a
node is always considered to be three digits long.
- Your keys should be at least 20 digits long, or more.
- Please try to use "FACADE" design pattern to implement
RSA
class - the front-end to other classes.
- Please try to use "ABSTRACT FACTORY" design pattern
to implement the
KeyPairGenerator
class.
- Please do not forget to take care of possibility of erroneous
user input (bad command-line arguments) in an intelligent
way using C++ exceptions.
- Have fun.
- Make sure that you submit your header
in the required format, and that you follow all the instructions
listed below on this page.
READING ASSIGNMENTS:
- [1]W. Ford, W. Topp "Data Structures with C++ Using STL",
2nd edition."
- 01/08/2004
- [1], Chapter 1.
- 01/15/2004
- [1], Chapter 2.
GENERAL PRACTICES AND PROCEDURES:
- Assignments will be distributed in class and posted on the class web page.
Current homework assignments are listed above on this page. Read the text
and stay a bit ahead of the lecture. Material from the reading part of an
assignment may appear on midterms and finals. Approximately seven
programming projects will be assigned over the course of the quarter.
Each project will require you to write a program in C++ to solve a
specific problem.
- All programming projects must be submitted electronically, by placing
your files in the "SUBMIT" folder in your account. Be sure to give your
files the EXACT name required (remember that case counts).
Computer programs must be submitted by the specified time on the due date.
No homework will be accepted by e-mail to the TA or to the instructor.
No late projects will be accepted.
Leave the homework files in your "SUBMIT" folder for the rest
of the course, even after they have been collected and graded.
You may be able to submit files remotely with ftp, but
it is best to make sure your submission works in the Lab before
you submit. If you wish, you may overwrite a previous submission
with a new version at any time before the due time on the due
date. Please do not store any files in your submit directory
other than those that are to be or have been collected. To
confirm that you have submitted correctly, run the checksubmit
program. This check generally requires a trip to the PIC Lab.
Your homework scores will be posted in your gradebook on
"my.ucla" web site along with
any other feedback from the Reader.
Please, check your gradebook on
"my.ucla" web site each week to verify your grades. This is
very important, it is the only way to know for sure that you actually
received credit for your assignment.
- Each program you submit MUST begin with the following
header:
/*
Your name
Your Student ID
Your e-mail address
I certify that the following represents my own independent work and
conforms with the guidelines of academic honesty described in the
course syllabus.
*/
Any homework submitted without this header will not be graded,
and you will receive zero credit for it.
- Your code should be as easy to read as possible. Use indentation
carefully and consistently to delineate levels of nesting.
Disjoint blocks should be well separated by concise and
informative comments. This will be worth at least 1 point of
every assignment. Although you are allowed a fair amount of
choice in style, please try to conform to the conventions used
in lecture and in the text.
- You may use the PIC Computer Laboratory in Boelter Hall 2817 to work on
your programming assignments. You can use any ANSI C/C++ development
environment for your projects in this class. A number of ANSI C/C++
development tools is installed on all PC's in the PIC Lab.
If you have your own computer and would like to work at home, you can
use your favorite C/C++ development environment. However, you must still
submit your program to your UCLA class account. Always compile and test
your programs on the lab machines before submission.
- Start working on programming assignments early. Do not wait until the
last minute to submit your work, as the lab may be full near critical
time. Deadlines for homework are strictly enforced.
- You are encouraged to discuss aspects of the course with other students,
and you may discuss the homework assignments in general terms with others.
You may also get help from the TA or the instructor in writing your
programs. However, the general rules of academic honesty apply to all
homework: each homework assignment must represent your own, independent
work. In particular, you may not copy any part of a program written by
someone else without citing the reference carefully.
- If you have a question on the way a homework was graded, you must contact
the instructor within one week of its return. No e-mail request for
regrades will be accepted, you must contact the instructor in person.
- Your programming will improve with practice. After finishing an
assignment, do not be afraid to experiment with your own programs.
Last modified on
by fedandr@math.ucla.edu.