Florida Tech, Spring 2002 - Jan. 8 to Apr. 25 - Tues. and Thurs., 12:30-1:45 PM, room 137EC
http://cs.fit.edu/~mmahoney/cse2050/
Students will learn to program in C++. Topics include the standard library, object oriented programming (data abstraction, inheritance, polymorphism), implementing data structures, and the UNIX development environment and portability considerations. Prerequisites: CSE2010 (Algorithms and Data Structures) or equivalent, experience in at least one other programming language.
How is my teaching? Review this course anonymously at TeacherReviews.com.
Code examples from the book
C++ Reference
Guidelines for Object Oriented Programming
Based on 100 points. 90-100=A, 80-89=B, 70-79=C, 60-69=D, 0-59=F
There will be 4 tests during the term including the final exam. Each will count equally. Your grade will be based on the highest 3 tests after dropping the lowest score. There will be no make-up tests for any reason. Fall 2001 exam solutions:
Spring 2002 Exam solutions:
Exam 1 solution. Exam 2 solution. Exam 3 solution. Final Exam solution.
Fall 2001 Exam solutions:
Fall 2001 syllabus and homework
Exam 1 solution.
Exam 2 solution.
Exam 3 solution.
Final Exam solution.
Spring 2001 Exam solutions:
Exam 1 solution.
Exam 2 solution.
Exam 3 solution.
Final Exam solution.
Assignments will be graded equally on documentation and readability and on whether it actually works. Programs are due at midnight. Programs turned in late will be penalized 20% per day, including non-class days, weekends, and holidays.
Programs must be turned in by email. I prefer that you send me one source code (.cpp) file as an attachment, or in the body of the mail message if your mailer doesn't supoort attached files. Limit line length to 80 characters. I do not need test cases by email, since I can test it myself. Do not send me executables, zip files, Word files, project files, etc.
You are permitted to receive help from other students or outside sources, however you must cite your sources in your program comments and your work must still demonstrate that you are capable of writing the program yourself. Copying code or allowing your code to be copied by other students is not allowed. See the Florida Tech Computer Science Honor Code for details.
All programs must be tested with g++ under UNIX (Solaris, Linux, etc.). You may use other systems for development if you wish (Windows or Mac), and then port them. If you do, your C++ compiler should be produced since 1998 so that it supports the standard library. If you prefer to develop under Windoes and port to UNIX, then I recommend DJGPP, available at www.delorie.com. Other free compilers are available at www.cplusplus.com/info/compilers/
All students will be enrolled in a mailing list and will be responsible for announcements posted to this list. You should be enrolled automatically, but I sometimes miss a few people, so if you do not receive an email by the second class letting you know, then you should subscribe by sending a blank email to fit-cse2050-subscribe@yahoogroups.com. You are also encouraged to post questions about C++ or your assignments to this list, and to answer questions posted by other students. To post messages, mail them to fit-cse2050@yahoogroups.com. Archived messages may be found at groups.yahoo.com/group/fit-cse2050/
Compile and run the "hello world" program on page 1 using g++. Add comments as described above.
Due Tues. Jan 22, 2002 (10 pts). Write a C++ program like the one in chapters 1 and 2, except that it prints a triangle around the greeting instead of a rectangle. For instance:
Please enter your first name: Matt * * * * * * * * * * * * * * * * Hello, Matt! * * * *********************
Be sure your documentation describes the program completely, including how you handle the case where the greeting can't be centered exactly.
Due Tues. Jan. 29, 2002 (10 pts). Write a program to sort files. This assignment is deliberately vague (like real world programming assignments), so you will need to write an analysis (program description) describing what it means for a file to be sorted and how the user specifies the file names. Give an example showing how your program would be run (what does the user type?), and a sample file before and after sorting. Put all of this in your documentation before the first line of code. I suggest you try man sort in UNIX for some ideas, but you don't have to do it this way.
You do not need to write a sorting algorithm. You can use the standard library function sort() on a vector of strings to do most of the work.
Due Feb. 12, 2002 (10 pts). Write a program to index a text file by line number. The program should take a file name as an argument, then print an alphabetical listing of all the words in the file, in lower case. Each word should be followed by a list of line numbers (separated by spaces on the same line of output) where the word appears. A word is any sequence of letters from a to z with no other characters in between. Upper and lower case are considered equivalent, i.e. "The", "the", and "THE" are all the same word and are listed as "the". If a word appears on more than 10 lines, list only the first 10 line numbers followed by "...". If a word appears more than once on a line, list the line number only once. The first line is line 1. If the program is run without a file name argument, read from standard input (cin). If the file does not exist, print an appropiate error message to cerr (so that the message will appear on the screen even when the output is redirected).
For example, suppose the file test.txt contains the following:
This is a test. THIS and this is another test. index test.txt (or index <test.txt) a 2 and 2 another 3 is 1 2 test 2 3 this 1 2
Due Tues. Feb. 26, 2002 (15 pts). Write a program to print calendars for any given month, for example:
cal Feb 2002 February 2002 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Your program should take as arguments:
Your program should define a class Month to represent a month and year using your choice of private representation. It must have the following public members:
Hints:
Due Mar. 26, 2002 (15 points). Modify assignment 4 (the file index program) to use a binary tree instead of a map. The output of the program should be the same. However, instead of a map<string, vector<int> >, you will use a Tree<string, vector<int> >. The templated class Tree<K, V> should have the following public members:
Since a Tree does not support iterators, you need to use the transform() function to print the index. For example, the word count program on p. 124 could be implemented as follows. (This would also be a good way to test your program).
// Print s and i on one line void print(const string& s, int& i) { cout << s << "\t" << i << "\n"; } // Prints an alphabetical list of words from input and number of times they each appear int main() { string s; Tree<string, int> counters; // Maps words to counts while (cin >> s) // Build the tree ++counters[s]; counters.transform(print); // Print the tree return 0; }
Due Apr. 23, 2002 (30 pts). Write a program for displaying ASCII graphics. The input should be a series of graphics commands from a file or standard input to draw lines, rectangles, text labels, etc. The output should be a drawing suitable for display on a text terminal of unknown dimensions. A drawing command is one line containing a keyword (not case sensitive) followed by a list of numbers separated by white space.
hline 0 2 9 line 0 0 0 4 3 -4 3 4 3 -4then the output is:
+--+ +--+ | | | | ---------- | | | | | +--+ |If the input is:
label 4 4 Hello World! box 2 2 15 4 vline 9 0 9 box 4 4 15 4 vline 10 0 9Then the output is
|| +----|---------+ | | | +--------------+ | | | | | Hello World! |-+ | | +--------------+ || ||
Your program should make appropriate use of object oriented programming techniques (data abstraction, inheritance, and polymorphism). For example, you might have classes Hline, Vline, Line, Box, and Label (some may be derived from others or contain others) with a common abstract base class Shape with a pure virtual method draw(). You should read the input into a polymorphic data structure such as a linked list of Shape or vector<Shape*> so that the objects can be drawn in reverse order of the input so that the first object appears on top. Objects could be drawn into a Buffer (another class), whose dimensions might be found by scanning the list of Shapes to find the maximum x and y, or be determined dynamically for each row during drawing. Then the Buffer would be printed to the screen using the << operator.
Be sure your analysis is clear, especially with regard to your extra graphical element, and any other details not specified in the assignment. For example, how is the input file specified? What happens if you draw at negative coordinates? What happens for invalid commands, the wrong number of parameters, or the parameters are not integers? In the code, be sure to comment classes, data structures, functions, methods, etc. so that I can understand how you applied object-oriented principles.