// This is the master plan for variables // Semantic errors // Scope // Storage class // Data compatibility - Casting/Coercion // Synthesis questions // Declaration // Initialization // Assignment // Referencing // ---------------------------------------------------------------- // Other factors that affect template hardness: // Assignment: // a constant // a simple expression // Referencing: // a print statement // just the variable // an expression involving the variable // // ---------------------------------------------------- // These are the actual learning objectives // 100 // Variable.Declaration.Correct // 125 // Variable.Declaration.Scope.Correct // including multiple scopes with multiple vars of same name // 150 // Variable.Declaration.Scope.Accessing variable out of its scope // 175 // Variable.Declaration.Accessing variable before declaring it // // 200 // Variable.Initialization // // 300 // Variable.Assignment.Single // includes simple, compound, increment, decrement etc. // 325 // Variable.Assignment.Multiple // illustrates that a variable can hold only one value, non-destructive read // 350 // Variable.Assignment.Self Referential // 375 // Variable.Assignment.Coercion // // 400 // Variable.Referencing.Correct // 425 // Variable.Referencing.Multiple // includes expression not affecting value of a variable, // 450 // Variable.Referencing.Referencing variable before initializing its value // 475 // Variable.Referencing.Referencing garbage value assigned to variable // // Referencing a variable before declaring it? // Assigning value of incorrect data type? // Variable.Input.Whole.Whitespace delimited // Variable.Input.Whole.Non-whitespace delimited // Note: above NOT applicable to Java if Scanner class is applied - same as Illegal format excepttion // Variable.Input.Real.Whitespace delimited // Variable.Input.Real.Non-whitespace delimited // Note: above NOT applicable to Java if Scanner class is applied - same as Illegal format excepttion // Variable.Input.Boolean.Legal // Variable.Input.Boolean.Illegal // Variable.Input.Input stream is empty // Variable.Input.Data type of next item in input stream incompatible with variable in input statement // SYNTHESIS LEARNING OBJECTIVES - DRAFT // Variable.Synthesis.Declaration (Single Vs Multiple?) // Variable.Synthesis.Initialization // Variable.Synthesis.Input // Variable.Synthesis.Assignment.Constant // Variable.Synthesis.Assignment.Expression // Variable.Synthesis.Assignment.Self-Referential // Variable.Synthesis.Referencing.Print // Variable.Synthesis.Referencing.Expression // ------------------------------------------------------------------------ // 100 // Variable.Declaration.Correct // ------------------------------------------------------------------------ // 125 // Variable.Declaration.Scope.Correct // including multiple scopes with multiple vars of same name # 125 Variable.Declaration.Scope.Correct ? Variable.{Declaration.Correct,Initialization,Assignment.Single} > {(){=;{=;<<;<<;}}} > Type: output Hardness: 50 # 126 Variable.Declaration.Scope.Correct ? Variable.{Declaration.Correct,Initialization,Assignment.Single} > {(){=;{=;<<;}<<;}} > Type: output Hardness: 60 // ------------------------------------------------------------------------ // 150 // Variable.Declaration.Scope.Accessing variable out of its scope # 150 Variable.Declaration.Scope.Accessing variable out of its scope > {(){=;{=;}<<;<<;}} > Type: debug Hardness: 40 # 151 Variable.Declaration.Scope.Accessing variable out of its scope > {(){=;{=;<<;}<<;}} > Type: debug Hardness: 40 // ------------------------------------------------------------------------ // 175 // Variable.Declaration.Accessing variable before declaring it // # 175 Variable.Declaration.Scope.Accessing variable out of its scope > {(){ = ;;;<< + ; = ;}} > Type: debug Hardness: 40 // ------------------------------------------------------------------------ // 200 // Variable.Initialization // Initialization - Reference // Initialization with expression - Reference // Initialization - Reference - Reference // Initialization - Reference - Assignment - Reference # 200 Variable.Initialization > {(){=;<<;}} > Type: output Hardness: 20 # 201 Variable.Initialization > {(){ = + 3;<<;}} > Type: output Hardness: 30 # 202 Variable.Initialization > {(){=;<<;<<;}} > Type: output Hardness: 20 # 203 Variable.Initialization ? Variable.Assignment.Single > {(){=;<<; = ;<<;}} > Type: output Hardness: 20 // ------------------------------------------------------------------------ // 300 // Variable.Assignment.Single // includes simple, compound, increment, decrement etc. // Declaration - Assignment - Reference // Declaration - Assignment with expression - Reference // Declaration - Assignment - Reference - Reference # 300 Variable.Assignment.Single ? Variable.{Declaration.Correct,Initialization} > {(){; = ;<<;}} > Type: output Hardness: 20 # 301 Variable.Assignment.Single ? Variable.{Declaration.Correct,Initialization} > {(){; = + ;<<;}} > Type: output Hardness: 30 # 302 Variable.Assignment.Single ? Variable.{Declaration.Correct,Initialization} > {(){; = ;<<;<<;}} > Type: output Hardness: 20 # 303 Variable.Assignment.Single ? Variable.{Declaration.Correct,Initialization} > {(){=;<<;=;<<;}} > Type: output Hardness: 40 # 304 Variable.Assignment.Single ? Variable.{Declaration.Correct,Initialization} > {(){=;<<;{=;<<;}}} > Type: output Hardness: 60 // ------------------------------------------------------------------------ // 325 // Variable.Assignment.Multiple // illustrates that a variable can hold only one value, non-destructive read // Declaration - Assignment - Reference - Assignment - Reference // Back to back multiple assignments # 325 Variable.Assignment.Multiple ? Variable.{Declaration.Correct,Initialization} > {(){; = ; = ;<<;} > Type: output Hardness: 50 # 326 Variable.Assignment.Multiple ? Variable.{Declaration.Correct,Initialization} > {(){; = ;<<; = ;<<;} > Type: output Hardness: 50 // Exchanging variable values # 327 Variable.Assignment.Multiple ? Variable.{Declaration.Correct,Initialization} > {(){=;<<;=;<<;=; = ; = ;<<;<<;}} > Type: output Hardness: 80 // ------------------------------------------------------------------------ // 350 // Variable.Assignment.Self Referential # 350 Variable.Assignment.Self Referential ? Variable.{Declaration.Correct,Assignment.Multiple} > {(){; = ;<<; = + 1;<<;}} > Type: output Hardness: 40 # 351 Variable.Assignment.Self Referential ? Variable.{Declaration.Correct,Assignment.Multiple} > {(){=;<<; = - 1;<<;}} > Type: output Hardness: 40 // ------------------------------------------------------------------------ // 375 // Variable.Assignment.Coercion # 375 Variable.Assignment.Coercion ? Variable.{Declaration.Correct,Assignment.Single} > {(){;=; = ;<<;<<;}} > Type: output Hardness: 80 // ------------------------------------------------------------------------ // 400 // Variable.Referencing.Correct // ------------------------------------------------------------------------ // 425 // Variable.Referencing.Multiple // includes expression not affecting value of a variable, # 425 Variable.Referencing.Multiple ? Variable.{Declaration.Correct,Initialization} > {(){=;<< + ;<<;}} > Type: output Hardness: 40 // ------------------------------------------------------------------------ // 450 // Variable.Referencing.Referencing variable before initializing its value // ------------------------------------------------------------------------ // 475 // Variable.Referencing.Referencing garbage value assigned to variable # 475 Variable.Referencing.Referencing garbage value assigned to variable ? Variable.Declaration.Correct > {(){;<<;}} > Type: debug Hardness: 40 # 476 Variable.Referencing.Referencing garbage value assigned to variable ? Variable.Declaration.Correct > {(){;;<< + ;=;=;}} > Type: debug Hardness: 40 // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ // REFERENCE VARIABLES // These are the actual learning objectives // 500 // RefVariable.Declaration.Correct // 525 // RefVariable.Declaration.Scope.Correct // including multiple scopes with multiple vars of same name // 550 // RefVariable.Declaration.Scope.Accessing variable out of its scope // 575 // RefVariable.Declaration.Accessing reference variable out of its scope // // 600 // RefVariable.Initialization // 625 // RefVariable.Initialization.Initializing a reference variable to refer to a pointer/another reference variable // // 650 // RefVariable.Assigning to a reference variable // // // 700 // RefVariable.Referencing.Correct // 725 // RefVariable.Referencing.Referencing variable before initializing its value // 750 // RefVariable.Referencing.Referencing garbage value assigned to variable // // ---------------------------------------------------------------------- // 500 // RefVariable.Declaration.Correct # 500 RefVariable.Declaration.Correct > {(){=;&=;<<;<<;}} > Type: output Hardness: 10 # 501 RefVariable.Declaration.Correct > {(){=;&=;<< + ;}} > Type: output Hardness: 10 // ---------------------------------------------------------------------- // 525 // RefVariable.Declaration.Scope.Correct // including multiple scopes with multiple vars of same name // ---------------------------------------------------------------------- // 550 // RefVariable.Declaration.Scope.Accessing variable out of its scope # 550 RefVariable.Declaration.Correct > {(){=;{&=;}<<;<<;}} > Type: debug Hardness: 10 // ---------------------------------------------------------------------- // 575 // RefVariable.Declaration.Accessing reference variable out of its scope // ---------------------------------------------------------------------- // // 600 // RefVariable.Initialization # 600 RefVariable.Initialization > {(){&=;<<;}} > Type: debug Hardness: 10 # 601 RefVariable.Declaration.Correct > {(){=;&=; = ;<<;<<;}} > Type: debug Hardness: 10 // ---------------------------------------------------------------------- // 625 // RefVariable.Initialization.Initializing a reference variable to refer to a pointer/another reference variable # 625 RefVariable.Initialization.Initializing a reference variable to refer to a pointer/another reference variable > {(){&=;&=;<<;<<;}} > Type: debug Hardness: 10 // # 626 // RefVariable.Initialization.Initializing a reference variable to refer to a pointer/another reference variable // > // {(){;&=;<<;<<;}} // > // Type: debug // Hardness: 10 // ---------------------------------------------------------------------- // // 650 // RefVariable.Assigning to a reference variable # 650 RefVariable.Assigning to a reference variable > {(){=;&; = ;<<;<<;}} > Type: debug Hardness: 10 # 651 RefVariable.Assigning to a reference variable > {(){=;&=;=; = ;<<;<<;<<;}} > Type: debug Hardness: 10 // ---------------------------------------------------------------------- // // // 700 // RefVariable.Referencing.Correct // ---------------------------------------------------------------------- // 725 // RefVariable.Referencing.Referencing variable before initializing its value // ---------------------------------------------------------------------- // 750 // RefVariable.Referencing.Referencing garbage value assigned to variable // ---------------------------------------------------------------------- // // Error with the variable to which reference variable points # 900 Variable.Referencing.Referencing variable before initializing its value > {(){;&=;<<;<<;}} > Type: debug Hardness: 10 # 901 Variable.Declaration.Scope.Accessing variable out of its scope > {(){{=;}&=;<<;<<;}} > Type: debug Hardness: 10 // Error with the variable to which reference variable points # 925 Variable.Referencing.Referencing variable before initializing its value > {(){=;;}} > Type: reorder Hardness: 10 // -------------------------------------------------------------------------- # 990 Variable.Declaration.Scope.Accessing variable out of its scope > {(){ =; =; ; =; =; =; =+; <<; <<; <<;}} > Type: state Hardness: 10 # 991 Variable.Declaration.Scope.Accessing variable out of its scope > {(){ =; =; ; << ; <<;}} > Input: " " > Type: state Hardness: 10 // -------------------------------------------------------------------------- // Variable.Input.Whole.Whitespace delimited // Variable.Input.Whole.Non-whitespace delimited // Variable.Input.Real.Whitespace delimited // Variable.Input.Real.Non-whitespace delimited // Variable.Input.Boolean.Legal // Variable.Input.Boolean.Illegal // Variable.Input.Input stream is empty // Variable.Input.Data type of next item in input stream incompatible with variable in input statement // Testing input statements - reading whole part of real as integer # 995 Variable.Input.Whole.Whitespace delimited > {(){ =;>> ;<<;>> ; <<;}} > Input: " " > Type: debug_output Hardness: 10 // Testing input statements - running out of stream input # 996 Variable.Input.Input stream is empty > {(){ =;>> ;<<;;>>;<<;>> ; << ;}} > Input: "\n " > Type: debug_output Hardness: 10 // Testing input statements - Illegal format error for last integer read # 997 Variable.Input.Data type of next item in input stream incompatible with variable in input statement > {(){ =;;>>;<<;>> ;<<;>>;<<;}} > Input: "\n \n" > Type: debug_output Hardness: 10 // -------------------------------------------------------------------------- // Templates here are for demonstration purposes // Included at the end so that regular practice does not pick up these templates // How to enter an output # 90 Demonstration > {(){=;<<;}} > Type: output Hardness: 10 // How to enter multiple outputs # 91 Demonstration > {(){=;<<;=;<<;<< - ;}} > Type: output Hardness: 10 // How to enter NO output # 92 Demonstration > {(){=;=;; = + ;}} > Type: output Hardness: 10