San Jose State University : Site Name

Navigation

Main Content

Working in Mars Mission Control, JPL

Ronald Mak

Department of Computer Science
Spring Semester 2018

Office hours: TuTh: 3:00-4:00 PM
Office location: ENG 250
E-mail: ron.mak@sjsu.edu
Mission Control, Jet Propulsion Laboratory (JPL)
NASA Mars Exploration Rover Mission

CS 144: Advanced C++ Programming


Section 1: Th 9:00 - 10:15 AM, room MH 233


Assignments


# Assigned Due Assignment
1 Jan 29 Feb 5 Watering plans

Sample solution: WateringPlans.cpp    output.txt
2 Feb 5 Feb 12 The Monty Hall Problem

Sample solution: MontyHall.cpp    output.txt
3 Feb 12 Feb 19 War and Peace

Input file: WarAndPeace.txt
Sample solution: WarAndPeace-v1.cpp    WarAndPeace-v2.cpp    output.txt
4 Feb 19 Feb 26 Student Scores

Input file: students.txt
Sample solution: students.cpp    output.txt
5 Feb 26 Mar 5 Roman Numerals

Input file: RomanNumeral.txt
Sample solution: RomanNumeral.h    RomanNumeral.cpp    RomanNumeralTests.cpp    output.txt
6 Mar 5 Mar 12 Big Pi

Sample solution: BigPi.cpp    output.txt
7 Mar 19 Mar 26 U.S. maps

Input files: boundary-data.csv   city-data.csv
Sample solution: Assignment7Solution.zip
8 Mar 26 Apr 9 Install wxWidgets
9 Apr 9 Apr 16 GUI-Based Rock-Paper-Scissors Game
10 Apr 16 Apr 23 Genealogy Tree

Sample solution: Assignment10Solution.zip
11 Apr 14 Apr 19 STL Vector, List, and Map

Input file: USConstitution.txt
Sample solution: Assignment11solution.zip


Lectures


Week Date Content
1 Jan 24 Slides: Course objectives; software to install; assignments; quizzes; exams; grading; what is C++; Hello World program

Example programs: helloworld.cpp  
2 Jan 29 Slides: Identifiers, variables, and keywords; input and output; cin input; #include and using namespace; basic data types; output field width; read from a text file; string type; assignment statements; type compatibilities and conversions; arithmetic; operator shorthand; if statement; while loops; named constants; Boolean operators; precedence rules; enumeration types; nested if statements; switch statement; increment and decrement operators; for loops; break statement; nested loops; Assignment #1

Example programs: nested.cpp
Jan 31 Slides: Predefined functions; type casting; programmer-defined functions: declarations, definitions, calls; void functions; top-down design; number translator example; scope and local variables; block scope; global constants and variables;

Savitch slides: 01 02 03 04 05
Top-down design example:
translator1.cpp   translator2.cpp   translator3.cpp   translator4.cpp   translator5.cpp
3 Feb 5 Slides: Overloading function names; call-by-value; call-by-reference; procedural abstraction; testing and debugging functions; assert macro; Assignment #2; streams; file I/O; stream name vs. file name; formatting output; output manipulators; passing streams to functions; character I/O; predefined character functions; eof function;

Savitch slides: 06 07 08
Example programs: swaps.cpp   assert.cpp
Feb 7 Slides: Character I/O; arrays; array initialization; array function parameters; multidimensional arrays; C strings; the standard string class; vectors
4 Feb 12 Slides: Assignment #2 sample solution; pointers; int vs. pointer to int; declaring and assigning pointers; pointers are addresses; address-of and dereferencing operators; new and delete operators; pointer parameters; typedef; using pointers to pass-by-reference; Assignment #3
Feb 14 Slides: Passing pointers by value and by reference; pointers and arrays; pointer arithmetic;

Savitch slides: 09
5 Feb 19 Slides: Assignment #3 sample solution; dynamic arrays; typedefs; char* and char**; C++ strings and vectors are better; Assignment #4; structures; structures are types; scope of member names; structure variables; object-oriented programming (OOP); classes; member functions; public and private members; constructors; abstract data types (ADT)

Savitch slides: 10
Dynamic array examples: DynamicArray1.cpp    DynamicArray2.cpp    DynamicArray3.cpp
Feb 21 Slides: Public vs. private; separate compilation; static member variables; static member functions; friend functions; operator overloading; overload <<

Class Birthday examples: Birthday3.zip   Birthday4.zip   Birthday5.zip   Birthday6.zip   Birthday7.zip   Birthday8.zip   Birthday9.zip
6 Feb 26 Slides: Assignment #4 sample solution; array of objects; destructors; vector of objects; copy constructor; "extra" constructor and destructor calls; Assignment #5 Roman Numerals

Savitch slides: 11 12
Class Birthday examples: Birthday10.zip   Birthday11.zip   Birthday12.zip
Feb 28 Slides: Overload >>; inline functions; class responsibilities; class relationships: dependency, aggregation, inheritance; UML diagrams; class diagrams; sequence diagram

Class Birthday example: Birthday13.zip
Inline examples: Inline1.h   InlineTest1.cpp   Inline2.h   InlineTest2.cpp   InlineTest3.cpp  
7 Mar 5 Slides: The chrono timer; a proposed C++ Date class; code to the interface; factory method design pattern; Day class design

Elapsed time example: TimeVector.cpp
Mar 7 Slides: The chrono timer; a proposed C++ Date class; code to the interface; factory method design pattern; Day class design

Elapsed time example: TimeVector.cpp
8 Mar 14 Slides: Object-oriented programming; inheritance; superclasses and subclasses; invoke superclass member functions; overridden member functions; polymorphism; virtual destructors; class hierarchies; the Liskov Substitution Principle; point-circle; vector-stack

Example programs: Employee1.zip   Employee2.zip   VirtualDestructor1.zip    VirtualDestructor2.zip    PointCircleRectangle.cpp   VectorStack.cpp
9 Mar 19 Slides: Midterm solutions; Assignment #6 sample solution; function and operator overloading; overloading vs. overriding; linked lists; Assignment #7

Example programs: AbiguousOverload.cpp   Complex.h   AddTest.cpp
Mar 21 Slides: A "safe" array type; overloaded assignment operator; overloaded subscript operator []; copy constructor; the "Big Three"

Savitch slides: 13
SafeArray example 1: (crashes) SafeArray1.h   SafeArray2.cpp   SafeArrayTests1.cpp
SafeArray example 2 (operator =): SafeArray2.h   SafeArray2.cpp   SafeArrayTests2.cpp
SafeArray example 3 (fix operator =): SafeArray3.h   SafeArray3.cpp   SafeArrayTests3.cpp
SafeArray example 4 (another fix operator =): SafeArray4.h   SafeArray4.cpp   SafeArrayTests4.cpp
SafeArray example 5 (overload []): SafeArray5.h   SafeArray5.cpp   SafeArrayTests5.cpp
SafeArray example 6 (copy constructor): SafeArray6.h   SafeArray6.cpp   SafeArrayTests6.cpp
10 Mar 26 Slides: Java and C++ interfaces; SimUDuck simulation game; code reuse; delegation; abstract superclass; "has a" better than "is a"; Assignment #8

Example programs: InterfaceJava.zip    InterfaceCpp.zip    SimUDuck.zip
Mar 28 Slides: Assignment #7 solution; dynamic casting; runtime type identification; multiple inheritance

Example programs: DynamicCast.zip    TypeId.zip    MultipleInheritance1.zip    MultipleInheritance2.zip    MultipleInheritance3.zip    MultipleInheritance4.zip
11 Apr 9 Slides: Model-View-Controller (MVC) architecture; events; event handlers; callback functions; inversion of control; wxWidgets; hello world example; buttons demo; Assignment #9

Example wxWidgets programs: wxHelloWorld.cpp    wxButtonsDemo.zip    MakefileButtonsDemo
Apr 11 Slides: Button and menu event handlers; wxWidgets sample programs; auto keyword; decltype pseudo-function; function objects; regular expressions; lambda expressions

Example function object programs: RandomInt.h    RandomIntTester.cpp    Summation.h    SummationTester.cpp
Example regular expression program: Regex.cpp
Example lambda expression programs: Person.h    PersonTest1.cpp    PersonTest2.cpp
12 Apr 16 Slides: Lambda expressions with capture; review of iteration; recursion; think recursively; recursive examples: factorials, multiplication, Fibonacci (iterative and recursive), member of, unique, reverse, Towers of Hanoi; linear search; binary search (iterative and recursive)

Savitch slides: 14
Malik slides: 06
Recursion examples: Factorial.cpp   Multiply.cpp   Fibonacci1.cpp   Fibonacci2.cpp   Fibonacci3.cpp   MemberOf.cpp   Unique.cpp   Reverse.cpp   permutations.cpp   Hanoi.cpp   BinarySearchIterative.cpp   BinarySearchRecursive.cpp
Apr 18 Slides: Mergesort; calculation puzzle; exception handling; exception classes; templates; template class "safe array" version 7; standard template library (STL); iterators; vector iterator example; reverse iterator example

Savitch slides: 15
Calculation puzzle: roundoff.cpp
Exception handling examples: exception1.cpp   exception2.cpp   exception3.cpp
Template function example: ExchangeTemplate.cpp
Template class example: Pair.h   PairTests.cpp
SafeArray example 7 (template): SafeArray7.zip
Vector iterator examples: IteratorVector1.cpp   IteratorVector2.cpp
13 Apr 23 Slides: STL list; hash tables; hash function; collisions; keys for successful hashing; collision resolution; separate chaining; open addressing: linear probing and quadratic probing; load factor; Assignment #11

Malik slides: 09
STL list example: ListTest.cpp
Apr 25 Slides: STL map; STL algorithms

STL map example: STL-Map.zip
STL algorithms example: AlgorithmsTest.cpp
14 Apr 30 Slides: Arrays of objects; constructors and destructors; vectors of objects; copy constructor; "extra" constructor and destructor calls; how a vector grows; dynamic arrays of objects; mysterious program crash; shallow copy; deep copy

Example programs: BirthdayArray.zip    BirthdayVector.zip    BirthdayCopyCtor.zip    BirthdayDynamic.zip    BirthdayDeepCopy.zip
May 2 Slides: Pointers vs references; raw pointers vs. smart pointers; unique pointer; shared pointer

Example programs: SmartPtrUnique.zip   SmartPtrShared.zip  
15 May 7 Slides: Namespaces; multithreaded programming; concurrency vs. parallelism; race condition; critical regions and shared resources; mutual exclusion; mutexes; sleep and wakeup; semaphores; Pthreads package

Example multithreaded program: officehour-mac.cpp
May 9 Slides: Move semantics; introduction to algorithm analysis; big-oh notation; how well does an algorithm scale; partitioning a list; quicksort; sorting videos

Example program: Move.zip


Goals


Advanced features of C++, including operator overloading, memory management, templates, exceptions, multiple inheritance, RTTI, namespaces, tools. We will also examine some of the features of modern C++, such as lambda expressions, smart pointers, and move semantics. We will develop interactive GUI applications and explore multithreaded programming. We’ll learn how to write efficient C++ programs that adhere to good design principles while avoiding pitfalls of the language.

Learning to program well in a language like C++ requires much practice! You should expect to write one or more programs each week. The programming assignments will become increasing more challenging during the semester.


Prerequisites


Department policy is to enforce
all course prerequisites strictly

CS 46B and CS 49C (with a grade of C- or better in each), or equivalent knowledge of object-oriented programming and C, or instructor consent.


Recommended books


C++ How to Program, 10th edition
Paul J. Deitel and Harvey Deitel
Pearson International, 2017
ISBN: 978-9332585737
Effective Modern C++
42 Specific Ways to Improve Your Use of C++11 and C++ 14

Scott Meyers
O’Reilly Media, 2014
ISBN: 978-1491903995
The C++ Standard Library
A Tutorial and Reference, 2nd edition

Nicolai M. Josuttis
Addison-Wesley Professional, 2012
ISBN: 978-0321623218


Software to install


Eclipse is an excellent integrated development environment (IDE) to use for developing C++ programs for this class.

If you are on the Windows platform, we strongly recommend running the Ubuntu operating system (a variant of Linux) in a virtual machine.

Useful tutorials: