Download presentation
Presentation is loading. Please wait.
Published byVirginia Hodges Modified over 9 years ago
1
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Summary and Exam COMP 102 2011 T1
2
© Peter Andreae COMP 102 Summary:2 Menu Where have we been? ie, what could the exam cover? Exam Structure Studying for the exam Friday 4p tutorial tomorrow. Last year's exam
3
© Peter Andreae COMP 102 Summary:3 Course & Teaching Evaluations Changes this year Videos: More accessible lecture videos Some tutorial videos Demo Videos UI class simpler, more consistent, more forgiving i/o for small programs revised all assignments (and lectures) Exercises in the assignments Labs were one 2 hour session instead of 2 x 1 hour sessions, focused on exercises. Equity help sessions More lecturer feedback on forum.
4
© Peter Andreae COMP 102 Summary:4 Where have we been? Defining methods statements, expressions, local variables, calling methods on objects creating new objects method headers with parameters returning values Calling static methods, main, Math, … Text based User interfaces using UI for print…, ask…, next…. Graphical output to DrawingCanvas coordinates rectangles, ovals, lines, colors
5
© Peter Andreae COMP 102 Summary:5 Where have we been? If statements, single if, with no else multiway (nested) if … else if … else if …else … nested if (…) { if (…) … else … } else {…} boolean expressions Data types: int, double, (& long, float ) boolean char String Object types (predefined, user defined) Interface types
6
© Peter Andreae COMP 102 Summary:6 Where have we been? Loops: while Structure with four parts break and return Nested loops Loops: for Standard pattern for numbers and arrays for (int i = 0; i<…; i++); “foreach” on arrays for (Thing th : myThings){… Files: Input and Output Output using PrintStream (print, println, printf) Opening files Input using Scanner (next, nextLine, nextInt, nextDouble,…) try … catch to deal with exceptions.
7
© Peter Andreae COMP 102 Summary:7 Where have we been? Classes and objects fields, constructors, methods: scope and extent of fields visibility specifiers (public vs private) intialising fields, constructors Multi class programs class diagrams modular design interface classes for “supertypes”
8
© Peter Andreae COMP 102 Summary:8 Where have we been? GUIs Buttons, TextFields, Sliders declaring listeners Defining method to respond to the buttons etc Defining methods to respond to the mouse. Arrays constructing new arrays arrays of primitive types (initially 0 or false) arrays of objects (initially null) accessing elements of arrays array[index ] arrays for lists (arrays with nulls, or keeping a count with the array) loops with arrays initialising arrays with = new int[ ]{val, val, … } 2D arrays and nested loops
9
© Peter Andreae Standard Patterns You Must Know Structure of a while loop: initialisation while ( do again condition ) { body increment } Structure of a for loop: for ( initialisation ; do again condition ; increment ) { body } COMP 102 Summary:9
10
© Peter Andreae Standard Patterns You Must Know Reading from a file: try { Scanner scan = new Scanner(new File( filename )); while ( scan.hasNext() ) { …. scan.next()…. or nextInt or nextDouble or … } scan.close(); catch (IOException e) { UI.println("File failed " + e); } COMP 102 Summary:10
11
© Peter Andreae Standard Patterns You Must Know Class describing an object with state: public class classname { // Fields type fieldname = initialValue ; ⋮ // Constructor public classname ( arguments ){ actions to set up the object } // Methods eg: set and get field values perform actions on object computations involving object COMP 102 Summary:11
12
© Peter Andreae Standard Patterns You Must Know Array where all cells are full: do something with each element (using or changing) for ( int i = 0 ; i < data.length ; i++ ) { …. data[ i ]…. } do something with each element, but not changing array for ( ElementType elem : data) { …. elem…. } COMP 102 Summary:12
13
© Peter Andreae Standard Patterns You Must Know Collection in an Array using nulls (Object values only) do something with each element (using or changing) for ( int i = 0 ; i < data.length ; i++ ) { if (data[ i ] != null) { ….data[ i ]…. } do something with each element, but not changing array for ( ElementType elem : data) { if (elem != null) { ….elem…. } COMP 102 Summary:13
14
© Peter Andreae Standard Patterns You Must Know Collection in an Array using array and count ElementType[ ] data = new ElementType[100]; int count = 0; do something with each element (using or changing) for ( int i = 0 ; i < count ; i++ ) { ….data[ i ]…. } add new element (using or changing) if ( count < data.length) { data[ count ] = value; count++; } COMP 102 Summary:14
15
© Peter Andreae Standard Patterns You Must Know 2D array do something with each element (using or changing) for ( int row = 0 ; row < data.lenth ; row++ ) { for ( int col = 0 ; col < data[row].length ; col++ ) { ….data[row][col]…. } COMP 102 Summary:15
16
© Peter Andreae Standard Patterns You Must Know Using an interface class for storing different kinds of values in the same place. Interface class defines a general type Array or variable holding general type Classes implementing subtypes of the general type must have all methods specified in interface class must have only fields and constructor COMP 102 Summary:16 genlType subtype 1 subtype 2 subtype 3 Class for collection array of genlType implements
17
© Peter Andreae COMP 102 Summary:17 Exam 3 hours, 180 marks (1 mark ∼ 1 minute) More time than in tests to go back. Exam Questions : ∼ 1/3 understanding code loops, conditionals, variables, files, objects with fields, arrays ∼ 2/3 writing code, loops files arrays using classes and arrays of objects defining/using interface classes GUI programs debugging code with loops
18
© Peter Andreae COMP 102 Summary:18 Studying for the Exam Previous exams Exams before 2006 may be useful practice, but used lots of different stuff, and emphasised Strings and chars Exams 2007-2010 more useful, but used System.out and System.in and had more complicated GUIs Checking your answers: Model solutions Study with other students Use BlueJ to check your answers (Sometimes, you will have to write extra code to set things up the way the question assumed.) Don’t forget the recordings of all the lectures
19
© Peter Andreae COMP 102 Summary:19 Hints for the exam We are looking for evidence you know stuff, not trying to trip you up (except occasionally). we do give partial marks Learn the syntax rules for java constructs (note that the exam itself will have many models for you) Use documentation if you forget method names We don’t expect you to remember every method and class; the documentation is to prompt you. Check your code by stepping through it on paper. Put your working down if it might help us give you marks
20
© Peter Andreae COMP 102 Summary:20 Where to from here? COMP 103 builds on COMP 102 Focuses on collections and algorithms Core course for Computer Science and Engineering MATH 161 Discrete Mathematics Core mathematics for Computer Science, and SWEN, and NWEN SWEN 102 Intro to Software Modeling Core course for Software Engineering. Required for Network Engineering Very helpful for Computer Science (required for several, but not all, 200 and 300 level courses) COMP 102 taught again in Tri 2
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.