ASSIGNMENT #1 Lesson: l_explain_translation Prerequisites: none Objectives: explain_translation Description: The lesson will explain the big picture of how to edit, compile and execute a C++ program. Presentation: With an graphical presentation, explain each of the following steps with rationale: (1) write or modify text program text (2) use a compiler/linker to generate executable form (3) execute the program Evaluation: Write an authroware simulation of the above process using similar graphical representation. A suggested script would be: (user action) double click "editor" (computer response) a file icon which represent a text program appears (user action) drag the file icon to compiler icon (computer response) executable icons appears (user action) double click on executable (computer response) program output This should be trivial to "pass", but hopefully the actions will help the student remember the lesson. ================================================================ Lesson: l_debug_process Prerequisite: explain_translation Objectives: debug_process Description: The lesson will describe and explain the process of debugging. Presentation: With the use of graphical representation, describe and explain the debugging process. The debugging process will include the following steps: 1. modify the text program in an editor 2. re-translate the program 3. execute the program note: (1) It should be emphasized that the program has to be re-translated (compile/link) after modifying the text program. Evaluation: Write a simulation of the above process using similar graphical representation as in l_explain_translation. ================================================================ ASSIGNMENT #2 Lesson: l_explain_program_parts Description: The student will be given the following program: #include "tutorial.h" void main(void) { cout << "Hello world!"; } The lesson will explain the various parts of the above program. It includes: 1. the preprocessor command - #include 2. the main function 3. statement 4. cout as an C++ object to perform some task 5. strings are in double quotes The objective is an *informal* understanding of basic program syntax. Evaluation: In an authoreware interactive session, present the student with a different program and ask the student to match the various parts of the program with descriptions. ================================================================ Lesson: l_read_multiple_parameters Description: Learn to read functions with multiple parameters Presentation: Explain that multiple parameters can be passed. Types and number must match. Actuals are copied to corresponding formals. Evalution: Student should write a single function to set the width and height of box: void SetSize(int width, int height) { box.SetWidth(width); box.SetHeight(height); } ================================================================ ASSIGNMENT #3 Lesson: l_integer Prerequisite: none Objectives: integer Description: The lesson will introduce to the student the integer data type. Presentation: The presentation will explain what these data types are and the characteristics. These include: 1. definition 2. examples 3. range of representation is machine-dependent, but at least +/-32K Evaluation: In order to test the knowledge taught, ask the student to do some exercise. Formats can be multiple choice or textual questions. Suggested exercises: 1. describe a constant and ask the student to type it in. It is trivial exercise. ================================================================ Lesson: l_char Prerequisite: none Objectives: char Description: The lesson will introduce to the student the char data type. Presentation: The presentation will explain what these data types are and the characteristics. These include: 1. definition 2. examples 3. range of representation, min/max Evaluation: In order to test the knowledge taught, ask the student to do some exercise. Formats can be multiple choice or textual questions. Suggested exercises: 1. describe a constant and ask the student to type it in. It is trivial exercise. ------------------------------------------- Lesson: l_float Prerequisite: none Objectives: float Description: The lesson will introduce to the student the float data type. Presentation: The presentation will explain what these data types are and the characteristics. These include: 1. definition 2. examples 3. range of representation, min/max Evaluation: In order to test the knowledge taught, ask the student to do some exercise. Formats can be multiple choice or textual questions. Suggested exercises: 1. describe a constant and ask the student to type it in. It is trivial exercise. ================================================================ ASSIGNMENT #4 Lesson: l_mult_div_op Prerequisite none: Objectives: mult_div_op Description: The student will learn about how to divide and multiply integers and real numbers. He/she will also be told the result of operating on mixing datatypes. Presentation: Topics covered: 1. Introduction of the * and / operators 2. simple arithmetic expressions 3. determine resulting datatypes when operating on mixed datatypes. 4. integer division in which the fractional parts are dropped 5. division by zero is an error Evaluation: The student will be asked to convert algebra expressions into c++ expressions and evaluate them. ================================================================ Lesson: l_add_sub_op Prerequisite: none Objectives: add_sub_op Description: The student will learn about how to add & subtract integers and real numbers. He/she will also be told the result of operating on mixing datatypes. Presentation: Topics covered: 1. Introduction of the arithmetic operators 2. simple arithmetic expressions 3. determine resulting datatypes when operating on mixed datatypes. Evaluation: The student will be asked to convert algebra expressions into c++ expressions and evaluate them. And/or give the type and value of some expressions. ================================================================ ASSIGNMENT #5 Lesson: l_op_precedence Prerequisite: arithmetric_op Objectives: op_precedence Description: The student will learn about the rules governing expressions with more than 1 arithmetic operator. Presentation: Topics covered: 1. correct syntax of an arithmetic expression (e.g. no 2 operators together) 2. grouping with parentheses 3. operator precedence: (1). unary - (2). *, /, % (3). +, - 4. associatively: right to left or left to right (huh? - I don't even know what C++ semantics say about evaluation order. Let's say something about it -RBD) Evaluation: Ask the student to do some exercises: (1) determine if a given expressions is correct (2) evaluate expressions Format Suggested: (1) Check off valid expressions (2) type in resulting value (3) select type by clicking Feedback: Explain why answers are correct or incorrect. ================================================================ ASSIGNMENT #6 Lesson: l_mult_declaration Prerequisite: l_read_assignment, data_constants Objectives: mult_declaration Description: The lesson will introduce multiple declaration syntax. Presentation: Describe multiple declaration: e.g. int num1, num2 Give some rationale. Evaluation: Ask student to write some declarations (type them in). ================================================================ Lesson: l_variable_usage Prerequisites: Objectives: Description: Learn how to use variables to replace numeric constants with a symbolic term. Presentation: Guide the student to rewrite a program by defining variables and substituting them for constants. For example, the program below, in which a box moves in a rectangular path, can be modify by defining variables to hold the position. Explain the rationale. The following program will be more elegant if we define variables to hold the initial x- and y-coordinates, and expressions like x + width to indicate the destination coordinates. #include "tutorial.h" void man(void) { box.MoveTo(50,50); Wait(100); box.MoveTo(100,50); Wait(100); box.MoveTo(100,100); Wait(100); box.MoveTo(50,100); Wait(100); box.MoveTo(50,50); } ================================================================ ASSIGNMENT #7 Lesson: l_multiple_assignments Prerequisite: variable Objectives: multiple_assignments Description: The lesson will explain what an assignment does and how it is useful. Presentations: Topics - 1. The datatype of the operand must match that of the variable. 2. operand can be an constant or a valid expression 3. The main concept: the value of a variable can be changed by assignment. (Prior to mastery of the multiple_assignments concept, students have only seen variable initialization, not assignment to modify a previous value). Some form of line-by-line simulation would be nice. Evaluation: Ask student to simulate and type output from the following: #include void main(void) { int num; num = 100; cout << num << endl; num = 200; cout << num << endl; num = num + 100; cout << num << endl; } ================================================================ Lesson: l_update_operators Description: Teaches +=. -=, *=, /=, %= Presentations: Explain short cuts: +=. -=, *=, /=, %= It is suggested that a small program will be shown to the student and explain how values stored in different variables change with assignments. Evaluation: More simulation of programs by student. ---------------------------- Lesson: l_inc_dec_operators Description: Teaches i++, i--, ++i, --i Presentations: Explain semantics of ++, -- Warn student against using these operators within expressions It is suggested that a small program will be shown to the student and explain how values stored in different variables change with assignments. Evaluation: More simulation of programs by student. ================================================================ ASSIGNMENT #8 Lesson: l_cout Prerequisite: (note: variables are not a prerequisite) Objectives: cout Description: The lesson will teach the student how do simple output. Presentation: Topics - 1. cout is used to output data 2. simple modifiers, esp. endl 3. examples Evaluations: Ask the student to write or modify a statement that outputs the result of some calculation. ================================================================ Lesson: l_cin Prerequisite: cout, variables Objectives: cin Description: The lesson will teach the student how do simple input. Presentation: Topics - 1. cin is used to enter data 2. cin : pause for user input until user finishes by pressing the return key 3. how to read in more than 1 input 4. examples Evaluations: Ask the student to write or modify a program which will read in 3 integers and output the sum. ================================================================ ASSIGNMENT #9 Lesson: l_function Prerequisite: graphic_lib Description: The lesson will explain how to write a function. Presentation: Revisiting the graphic library, the student is guided to add a function, jump(), to the original program. The function would be like: void jump (void) { box.MoveRel(0,-50); Wait(1000); box.MoveRel(0,50); Wait(1000); } The student will be shown how to do a function call, the relation between the calling function and the called function. Topics - 1. function declaration - avoid parameters and return values for now 2. syntax and structure of a function ================================================================ Lesson: l_function_nesting Prerequisite: function Description: Teach nested function calling and return Presentation: Use a simple example and create an animation showing a return stack and the path of the program counter through 2 nested function calls and returns Evaluation: Ask student to mentally simulate a similar example with print statements and type the expected output, or click on statements in sequence. ================================================================ ASSIGNMENT #10 Lesson: l_call_by_value Prerequisite: function, graphics Objectives: call_by_value Description: The lesson will explain one form of parameter passing: call-by-value. Presentation: Show syntax for parameters Show how values are copied from actuals to locations named by formal parameters Use example(s) with only one parameter Evaluation: The student will be instructed to modify a program with the following function: void jump (void) { box.MoveRel(0,-50); Wait(500); box.MoveRel(0,50); Wait(500); } The new function will take an argument - height- which will determine how high the box will jump. ================================================================ Lesson: l_return_value Prerequisite: call_by_value Description: The student will write a function that returns a value according to a specification. Presentation: Give a specification, e.g. compute the square of a number. Show how to write a function with one parameter. Describe type of return value. Describe return statement. Evaluation: Give a specification, e.g. Farenheit to Centigrade. Get use to write the function. How to evaluate in Authorware: select and drag pre-existing program lines to form complete function, or write one line at a time. ================================================================ ASSIGNMENT #11 Lesson: l_graphic_lib Prerequisite: data_constants, compile_and_run, explain_program_parts Description: The lesson introduce the student to the graphical library which will be used as a teaching aid Presentation: Using an authorware animation, the student will be shown the following piece of program and what it will do. The lesson will give a brief overview of each part of the program but need not explain the mechanism of class and objects. The objective is to let the student match the statement with their effect on the graphical objects. #include "tutorial.h" rectangle box; void main(void) { box.MoveTo(100,100); box.SetHeight(50); box.SetWidth(20); WaitEvent(-1); } Evaluation: Ask the student to construct a similar program by reordering statements. It can be done by dragging text object in an authorware interactive session. ================================================================ Lesson: l_graphic_lib_2 Description: Describe more components of the graphical library. Presentation: Describe line object (and line.EndAt(x, y)) and more methods: SetFillColor(color), SetLineColor(color), and MoveRel(x, y). Give an example program. Evaluation: Get student to make another simple program. ================================================================ ASSIGNMENT #12 Lesson: l_ if_else Prerequisite: rational_exp, graphic_lib, cin, cout Objectives: if_else Presentation: The lesson will teach the student how to write a if-else statement to instruct the computer to select one of 2 sets of statements. It will show the student an example of a if-else statement and walk the student through the execution. The following is an example the lesson will walk through with the student and explain how the color is selected. #include "tutorial.h" rectangle box; void man(void) { int color; cout << "Type 1 for a red box or 2 for a blue one"; cin >> color; if (color==1) box.SetColor(CLR_RED); else box.SetColor(CLR_BLUE); } Topics - 1. syntax : if (rational expression) statement1; else statement2; 2. explain how the statement is evaluated. Evaluation: Write a if-else statement which output "POSITIVE" if the given number is positive else output "NEGATIVE". Actually, something with graphics would be more interesting. ================================================================ Lesson: l_if Prerequisite: if_else Description: if-statement without else Presentation: Show syntax, semantics for if without else. Evaluation: The student writes an if statement in a simple graphics program. ================================================================ ASSIGNMENT #13 Lesson: read_braces Description: Teach student how to read a program with braces Presentation: Explain syntax, semantics of "{ stmts }" Evaluation: Ask student to mentally simulate and produce the output for: if (condition) { stmt1; stmt2; } else { stmt3; stmt4; } ================================================================ Lesson write_braces Description: Student can use braces to group statements in a program. Presentation: Give student a program to write using graphics library. Evaluation: Get student to write program. How to evaluate in Authorware: select and drag pre-existing program lines to form complete function, or write one line at a time. ================================================================ ASSIGNMENT #14 Lesson: l_nested_if Prerequisite: if-else, write_braces Description: The lesson will teach the student how to read nested-if statements. Presentation: The lesson will state a problem of selecting among more than 2 choices and suggested how to solve the program of using nested if statements. E.g. if (exp1) { statement1; } else { if (exp2) statement2; else statement3; } Evaluation: Ask user to write program to pick the maximum of 3 numbers. How to evaluate in Authorware: select and drag pre-existing program lines to form complete function, or write one line at a time. ================================================================ Lesson: l_if_else_chain Description: Teach if-else chain construction Presentation: Explain a program similar to this one: if (exp1) statement1; else if (exp2) statement2; else if (exp3) statement3; ... else statementn; An example would be: if (score >= 90) grade='A'; else if (score >=80) grade='B'; else if (score >= 70) ... (Note: I really hate these "gradiing program" examples - can you think of a way to use the graphics library to accomplish the same thing?) Evaluation: Get user to write something similar, e.g. decode a command letter to modify a graphical object ================================================================ ASSIGNMENT #15 Lesson: l_switch Prerequisite: nested_if Objectives: switch Description: The lesson will teach the student how to write a switch statement to do multiple selection. Presentation: Show the student a selection problem solved by if-else chain. Example: if (score >= 90) grade = 'A'; else if (score >= 80) grade = 'B'; else if (score >= 70) grade = 'C'; else if (score >= 60) grade = 'D'; else grade = 'R'; (Note: I really hate these "gradiing program" examples - can you think of a way to use the graphics library to accomplish the same thing?) Explain how this could be changed to a switch statement which perform the same task. Hint: divide the score by 10 Topics - 1. syntax switch(expression) { case value1: statement1; statement2; ... break; case value2; statementm; statementn; ... break; . ... default: statementx; statementy; } 2. explain how the switch statement is evaluated. The student will understand the keywords switch, case, default and break. Evaluation: Ask the student to rewrite a if-else chain to a switch statement. ================================================================ ASSIGNMENT 16: Lesson: l_while Prerequisite: rational_exp Objectives: while Description The lesson will teach repetition in the form of a while statement. Presentation: Show the student a simple example like this: A program which will ask the student to guess a number between 1 and 10. The program will repeat to ask the student until the student is right. After initial discussion, show the student a trace of the program variables using authorware graphics. Topics covered- 1. the need for repetition in programming 2. syntax of the while statement while (expression) statement 3. explain the flow of iteration using a flow chart 4. infinite loop Evaluation: 1. Show the student pieces of code, ask them to identify incorrect syntax, times of execution, infinite loop... 2. Show the student pieces of code, ask them the value of variables before and after execution. 3. Given flow chart diagrams, ask the student to generate C++ codes by matching. ================================================================ Lesson: loop_variable Prerequisite: while Description: Show how to initialize a loop variable, test it and update it in the loop Presentation: Use a graphic object as the "loop variable": Initially place it somewhere and use a loop to make the object move to the right while it is on-screen. Evaluation: Ask user to modify the loop program in some interesting way. (Move left?) ================================================================ ASSIGNMENT 17: Lesson: l_for_basic Prerequisite: exp, graphic_lib Objectives: for_basic Description: The lesson will teach basic form of a for loop. Presentation: Show the basic form of a for loop, e.g for (i=0; i<10; i++) { box.MoveRel(0,-5); Wait(20); Topics - 1. syntax for (init_statement; test_exp; iteration_exp) body_statement 2. explain how the initialization is performed, the test expression is evaluated. 3. The loop body is executed a fixed number of time Evaluation: 1. Show the student pieces of code, ask them to identify incorrect syntax, number of iterations, infinite loop... ================================================================ Lesson: l_for_read Prerequisite: l_for_basic Description: read and understand a for loop in a small program. Present a problem of writing an animation. Step through how to write a function - jump(). #include "tutorial.h" rectangle box; void jump(void) { int i; for (i=0; i<10; i++) { box.MoveRel(0,-5); Wait(20); } for (i=0;<10;i++) { box.MoveRel(0,5); Wait(20); } } void main(void) { box.MoveTo(50,50); jump(); } Evaluation: Show the student pieces of code, ask them the value of variables before and after execution. 3. Given flow chart diagrams, ask the student to generate C++ codes by matching. ================================================================ ASSIGNMENT #18 Lesson: l_for_use Prerequisite: l_for_read Description: Use a for loop in a small program. Presentation: specify a small that could use a for loop, ideally using graphics objects. Evaluation: See that the student writes the program. How to evaluate in Authorware: select and drag pre-existing program lines to form complete function, or write one line at a time. ================================================================ Lesson: l_loop_design Prerequisite: for, while Objectives: loop_design Description: The lesson will discuss general design decision with using loops. Presentation: Topics- 1. Discuss the basic decisions that one have to make when writing a loop (for/while). This includes initial conditions, preconditions, actions in loop body, number of iterations or exit on conditions 2. For a fixed number of iterations, a for-loop using an index variable will do the job. In the example below, the index variable will go from 0 to N-1. For-loop is very suitable for counting. for (i=0;i 0: box.SetWidth(width); box.SetHeight(4000 / width); otherwise: do nothing Evaluation: -- none -- (Can you think of anything?) ================================================================ Lesson: l_relational_operators Description: Explain relational operators Presentation: < > == != <= and >= Emphasize the difference between = and == results: 1 meaning "true", 0 meaning "false" Give some examples Evaluation: Ask user to evaluate some expressions ================================================================ ASSIGNMENT #28 Lesson: l_compound_booleans Description: Explain compound boolean expressions using &&, !, and || Presentation: Explain that a <= b <= c does not have the normal mathematical meaning Explain how to rewrite as (a <= b) and (b <= c) and code as (a <= b) && (b <= c) Explain &&, !, and !! Emphasize using () for grouping Evaluation: Ask user to evaluate some expressions ================================================================ Lesson: l_write_compound_booleans Description: Master compound boolean expressions by writing some Presentation: Explain short-circuit evaluation Evaluation: Ask user to write some compound boolean expressions ================================================================ ASSIGNMENT #29 Lesson: l_accumulation Prerequisite: arrays Description: Teach student how to compute a sum of N elements Presentation: Describe how this program works: #define N 5 int numbers[N] = { 10, 15, 23, 19, 105 }; void main(void) { int n; int sum; n = 0; sum = 0; while (n < 5) { sum += numbers[n]; } cout << "The sum is " << sum << endl; } Evaluation: Ask user to identify and fix errors in a buggy function that sums N elements of an array. ================================================================ Lesson: l_for_accumulation Prerequisite: arrays Description Teach students how to compute a sum of N elements using a for loop Presentation: Similar to l_accumulation, only use for instead of while Evaluation: Ask user to write a function that sums N elements of an array, perhaps by dragging "canned" statements to make Authorware evaluation easier. ================================================================ ASSIGNMENT #30 Lesson: l_while Description: Design a "bouncing ball" animation. Presentation: In this lesson, we'll design a bouncing ball animation. The ball will be "dropped" with an initial velocity of zero, and it will bounce with a fraction of it's impact velocity. Break down program into components: while loop iterates on each time step UpdateVelocity computes a new velocity (by subtracting acceleration constant from current velocity) UpdatePosition computes a new position (by adding velocity to y coordinate) While loop must test for termination: terminate when velocity drops below 1 Exercise: write each component of the program, to author a component, student can "fill in the blank" for missing expressions, select from a pool of statements and drag them into place, multiple choice from different code fragments, or just type in the code (but the latter is hardest to evaluate) (NOTES: You may wish to break this up into a sequence of short presentations followed by a coding task. In the final tutor, the student will use this design as the basis for a "real" program to be compiled, executed, and debugged, so it is appropriate to do a fair amount of hand-holding and guiding in this interactive exercise.) ================================================================ ================================================================ ASSIGNMENT #31 Lesson: l_lifetime Description: Explain how and when objects/variables are created and destroyed. Presentation: Describe a global variable - simple case Describe a local variable - when does it exist, when does it stop existing? Explain the idea that a new instance is created each time a local scope is entered. Can use graphic objects here, since graphic objects created locally will be destroyed when the scope exits. Evaluation: Ask student to simulate an execution with graphic objects. ================================================================ Lesson: l_scope Description: Explain the scope of identifiers and that local identifiers can hide a more global one. Presentation: Talk about static nesting structure and static scoping rule. Give examples. Evaluation: Make up some simple examples where 1. a function tries to reference a local variable to main (a bug) 2. a function references (e.g. prints) variables defined at multiple nesting levels Ask user to spot bugs and otherwise simulate the program and type the output ================================================================ ASSIGNMENT #32 Lesson: l_recursion_concept Description: Explain concept of recursion Presentation: explain factorial anchor case, trivial case, or basis inductive case or nontrivial case develop psuedocode and show animation of execution: 5! = 5 * 4! 4! = 4 * 3! 3! = 3 * 2! etc., the computation elaborates, then return values are substituted and the computation collapses, leaving the result Evaluation: Make up a similar recursive function and ask user to compute the result of some function applications. ================================================================ Lesson: l_recursive_code Description: Code factorial as a C++ function. Presentation: Explain a Factorial function in C++ Evaluation: Ask user to reconstruct the function by dragging statements to the proper place. ================================================================ ASSIGNMENT #33 Lesson: l_recursive_print Description: Explain a function to print digits in reverse recursively Presentation: Go through the recursive algorithm to print a number one digit at a time (in reverse). Show a stack simulation Evaluation: See if the user can simulate the algorithm by interactively allocating and filling in stack frames. (NOTE: most assignments are 2 small lessons, this simulation seems fairly difficult, so Assignment #33 has just one lesson) ================================================================