Florida Tech, Fall 2003 - Aug. 26 to Dec. 4 - Tues. and Thurs., 12:30-1:45 PM, room S112
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, or experience in at least one other programming language (preferably Java).
How is my teaching? Review this course anonymously at TeacherReviews.com.
Code examples from the book
Introduction to C++ (The short version)
C++ Reference (The long version)
Guidelines for Object Oriented Programming
Based on 100 points. 90-100=A, 80-89=B, 70-79=C, 60-69=D, 0-59=F. Grade = (highest 3 of 4 exams)/6 + (sum of homework grades)/2.
There will be 4 tests during the term including the final exam (on Dec. 10, 3:30 PM). 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 2003 Exam Solutions
Exam 1 solution.
Exam 2 solution.
Exam 3 solution.
Final Exam solution.
Spring 2003 Homework and Exam Solutions
Spring 2003 syllabus and homework
Exam 1 solution.
Exam 2 solution.
Exam 3 solution.
Final Exam solution.
Fall 2002 Homework and Exam solutions:
Fall 2002 syllabus and homework
Exam 1 solution.
Exam 2 solution.
Exam 3 solution.
Final Exam solution.
Spring 2002 Homework and Exam solutions:
Spring 2002 syllabus and homework
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 support 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. Sept. 9, 2003 (10 pts). Write a C++ program like the one in chapters 1 and 2, except that it prints an octagon 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 exactly how many stars are on each side as a function of the length of the name. You have some flexibility here, but your program must do exactly what your analysis says it does.
Write a program to compare files and show the differences, if any (10 points). The program has two parts worth 5 points each.
Part 1, due Sept. 16. Write the analysis. Do not write any code. The analysis should be detailed enough so that if I am given any two files, I know what to type to run the program, and I know exactly what the output should look like. For example, suppose I have the following 3 files:
file1.txt file2.txt file3.txt This is This is This is a a yet test. test. another Again. test.What commands do I type to compare two of the files, and what will the output look like for each pair? Write the analysis as a comment in a .cpp file. The analysis will be graded on completeness. I have deliberately left the assignment vague. It is up to you to fill in the details.
Part 2, due Sept. 23. Write the program so that it agrees with the analysis. You may change the analysis or not, but include it in your program in either case.
Due Oct. 15, (20 pts). Write a templated Set container. A Set represents a collection of elements of identical type, without duplicates. A Set supports union, intersection, difference, equality and subset relations, adding, removing, and testing for elements, size, implicit conversion to 1-element Set, and output. Specifically,
Set<T> a, b=a; // Declares a and b to be empty sets with elements of type T Set<T>(x) // Converts x (type T) to {x}, a 1 element set containing x a + b; // Union of sets a and b a * b; // Intersection of sets a and b a - b; // Difference (the set of elements in a but not b) a += b, a -= b, a *= b; // Equivalent to a=a+b, a=a-b, a=a*b a == b; // True if the sets are identical a < b // True if a is a proper subset of b (a != b) a > b, a <= b, a >=b, a !=b // have their obvious meanings a.in(x) // True if x is an element of a a.size() // The number of elements in a cout << a; // Prints elements enclosed in {} and separated by commasObjects may be implicitly converted to 1-element sets, e.g.
a += x; // Insert x (type T) into a a -= x; // Remove x from a b = x * a; // Assign the intersection of {x} and a to bT is any type with a total ordering, e.g. any type that could be sorted, such as Set<int>, Set<string>, or Set<vector<double> >. Note that a Set is only partially ordered (it is possible that neither a < b, a == b, nor a > b is true), so a type like Set<Set<string> > does not have to be supported.
If T can be printed to cout, the a Set<T> should be printable as well. It should be output as a comma separated list of elements in any order, without white space, and enclosed in braces. e.g.
Set<string> a = "hello"; a += "world"; cout << a << endl; // {hello,world} or {world,hello}Be sure that const operations are properly supported.
const Set<int> a=3, b=a; if (a == b && a.in(3) && a - b == Set<int>()) { cout << a+b+5 << endl; // {3,5} cout << ((2+a-3+4)*(b+4)).size() << endl; // 1 }Turn in a header file only, named set.h. I will test it by #including it in a test program. Your header file should not contain test code or using statements. All code should be templated (or inlined). Your header should work with the test program settest.cpp
Solution (rename to set.h)
Set<string> s; // Insert some values into s const Set<string> cs = s; Set<string>::const_iterator ci = s.begin(); // OK // Set<string>::iterator i = cs.begin(); // Compiler error if (find(cs.begin(), cs.end(), "hello") != cs.end()) cout << "hello is in sets s and cs\n";
Write a program comparing the words in two files. Your program should output the following:
List the words on one line, separated by spaces. If there are more than 10 words in any list, just print the first 10. In any case, print the actual number. For example, if file1 is "this is a test" and file2 is "this is another test", then your output should be:
5 word(s) in either file: a another is test this 3 word(s) in both files: is test this 1 word(s) in file1 but not file2: a 1 word(s) in file2 but not file1: another
Implement your program by reading the two files into two sets and using set operations and iterators to print their contents, e.g.
cout << (set1+set2).size() << " word(s) in either file:"; print(set1+set2); // Print first 10 elementsWrite your code in such a way that the following are tested:
Be sure your analysis fills in any details I've omitted, such as how to run the program, how you specify the input files, the exact definition of "word", whether word comparison is case sensitive, etc.
You may use my solutions to previous assignments as starting points, but acknowledge your sources.
Turn in ONE file, a .cpp file which includes both your Set class and your program.