Professor Sana Odeh's V22.0002.003, Spring 2010: Course Lectures, Readings & examples:

 

Helpful Java Resources:

Date

Topic/Special

Readings

W 01/20

Course Introduction

Link to Professor Deena's tutorial for transitioning from Python to Java

Course Introduction
M 01/25

Review of Variables, Primitive Data Types, and Control Structure

Class examples: ComputeArea.html, Calculator.java, FahrenheitToCelsius.html , DisplayUnicode.html

More Programs from chapter 2:
SalesTax.html, ComputeLoan.html, ComputeChange.html, ShowCurrentTime.html, DisplayTime.html

------------------
More Programs from chapter 3 slides:
LeapYear.html
, LearnAddition.html, ComputeTaxWithSelectionStatement.html, SubtractionTutor.html, GuessBirthDate.html

Also see corresponding notes and lectures from my Spring 0002 class

Readings: Chapter 1, 2 & 3
See Java Review Sheet for summary of Variables, Primitive Data Types, and control Structure

Liang Chapter 2

Liang Chapter 3

W 01/27

Topics continued from above:

Get data from user using JOptionPane class & use Control Structure
(nested if - else if):
Calculator2.java

Get data from user using JOptionPane class & use Control Structure (Switch() ): Calculator3.java,

Using Scanner class to input data: ScannerTest1.txt , ScannerTest2.txt, TestScanner.html , Calculator4.java

 

Also see corresponding notes and lectures from my Spring 0002 class

Using the Scanner Class to input data (read data from an input stream (the keyboard since we are using System.in))

 

Reference (Only these methods for now):
Scanner data = new Scanner(System.in); // create a scanner object

String variablename = data.next() // Reads next "token", a "word" stops when finds white space

int variablename = data.nextInt() // reads an integer value.


double variablename = data.nextDouble() // reads a double value.

String lineoftext = data.nextLine() // Reads a line of text

* use System.out.println() before using Scanner class's methods to inform user of what type of data to enter.

M 02/01

Repetition Structure(Iterations using Loops): Calculator5.java , Calculator6.java

More programs from chapter 4 slides: SubtractionTutorLoop.html, SentinelValue.html, TestSum.html, TestMultiplicationTable.html, GreatestCommonDivisor.html, FindSalesAmount.html, PrintPyramid.html, TestBreak.html, TestContinue.html, PrimeNumber.html
--------------------

Also see corresponding notes and lectures from my Spring 0002 class

 

Readings: Chapter 4 Liang Chapter 4

 

 

W 02/03 Same as above  
M 02/08

Methods: Calculator7.java

More programs from chapter 5 slides: TestMax.html, TestPassByValue.html, TestMethodOverloading.html, ComputeTaxWithMethod.html, PrintCalendar.html, PrintCalendarSkeleton.html

Readings: Chapter 5: Liang Chapter 5Converting from and to Binary, Decimal and Hex numbers: See chapter 1 lecture (slides 19 - 26) needed for Assignment 1
W 02/10 NYU canceled class (snow storm)  
W 02/17

One Dimensional arrays: Arrays lecture part I (slides 1 - 69)

Programs from chapter 6 slides:

Array1.txt, Array2.txt, Array3.txt, Histogram.txt, RollDie.txt, StudentPoll.txt, TestPassArray.txt, MakeHot.txt, MakeArrayInMethod.txt, TestCopyArray1.txt, TestCopyArray2.txt, TestCopyArray3.txt

Also see corresponding notes and lectures from my Spring 0002 class

Readings: Chapter 6 (6.1- 6.6)

Arrays lecture part I (slides 1 - 69)

 

 

 

M 02/22

Running a program from the command line and passing arguments to main

Formatting numbers to output specific decimal values: formattingDemo

Example: Computing area of a circle using static methods: Compute area1
, compute area2,

 

Readings: Chapter 7 (chapter 7: 7.1 – 7.4)

Chapter 7 lecture notes (objects and classes)

(ONLY slides 1- 32 and 37 - 48 )

W 02/24

Introduction to Object Oriented Programming:
OOP (Objects and Classes) I
:
Compute area1 ,compute area2,

Using OOP to design a class for Circle to model its properties and behavior) : oop Circle Class v1 ,

Readings: Chapter 7 (chapter 7: 7.1 – 7.4)

Chapter 7 lecture notes (objects and classes)

(ONLY slides 1- 32 and 37 - 48 )

M 03/01

OOP (Objects and Classes) II

Classes, objects, instance fields and methods, Static fields and methods:

example1: TestCircle1

Example2 TestCircle2 (with a constructor and a static variable)

Classes with Constructors:

TestCircleWithConstructors

 


Readings: Chapter 7 (chapter 7: 7.4 – 7.7- 7.8,

Chapter 7 lecture notes (objects and classes)

(ONLY slides 1- 32 and 37 - 48 )

W 03/03

OOP (Objects and Classes) III

Classes with constructors, private fields, Accessors (use with Private fields) and with static variables and methods:

1) Circle example 3, TestCircle example 3

Worksheet for the above example: (complete Circle example with UML)

2) Student example using private fields, and accessors

  • The TestStudent class (client/driver class or class with main method) and the Student (Data Type or class with constructors) are in separate files but in the same folder/project/application.

 

 

 

 
M 03/08

Midterm Review: Midterm Exam 3/8 (in class)

How to study for the midterm:

1) Read from required book chapters:

  • Chapters 1 - 5
  • Chapter 6 (6.1 to 6.6) ONLY
  • Chapter 7 ( 7.1 - 7.4 and 7.6 to 7.8 ) ONLY.
    • About 70% of the exam will focus OOP concepts:

2) Review the homework

3) Review lectures and examples posted on the class website.

4) Make sure that you understand OOP concepts from chapter 7 ( 7.1 - 7.4 and 7.6 to 7.8 ). Also, make sure that you know how to provide the UML.

Concepts: What is a class, how do you instantiate objects from a class, private fields, how do you access and change these fields using getters and setters methods, static fields and methods, and instance fields and methods.

5) Make sure to review Circle and UML discusses in class: complete Circle example with UML(pdf file)

Circle example 3, TestCircle example 3

6) Review Student example discussed in class:

Student example using private fields, accessors and static variables

  • The TestStudent class (client/driver class) and the Student (Data Type: Class with constructors)
  • Both classes are in separate files in the same folder/project/application.

7) Practice the Midterm Sample questions (Work on questions 3, 4 and 5 ONLY). Skip Recursion and multi Dimensional arrays questions)

 

W 03/10    
  Spring Break  
M 03/22 and 3/24

More on Classes and Objects:

Using Keyword (this):Rectangle.txt, TestRectangle.txt

Demonstrating Arrays Objects: TotalArea.txt

Demonstrating passing objects to methods
TestPassingObject.txt

Demonstrating object with a member Object
Employee.txt, EmployeeTest.txt, Date.txt

Coin Game: The Coin Game example-- should be helpful to solving this assignment ( Assignment # 3). See Question # 4 from sample midterm exam .

 

Chapter 7
03/29 and 3/31

Multidimensional dimensional Arrays:

TestLength, GradeExam.txt, Add two matrices,

Example of a Simple Bingo game using Multidimensional arrays: Bingo

Readings: Chapter 6
Multidimensional dimensional Arrays

Arrays II(starting at slide 99)

04/05 and 4/07

File I/O (Reading data from a file and writing data to a file within a program): Chapter 8 (pages 283- 291)

Java has many techniques to read/write to a file (I/O):

1) Simple example using File class:

2) Reading from File: A simple example using Scanner and File class:

Read from file || life2.dat (you can use any data file for this example but you need to change the name of the file)


To read and write from file, you should use java.util.PrintWriter (to write and append to file) and java.util.Scanner classes (to read from file). Both of these classes are high-level and easy to use.

Two examples that will help read from files for assignment # 4 (Game of life):

1) Initializing a TicTacToe board from data in a file called tic.dat (helpful for assignment#4): Three files needed:

Version #1: TestFileStringReader2.java ||FileStringReader.java || tic.dat

Version #2: Same example as above but using Scanner class (easier to use and more efficient):

ScannerFileReader || TestFileScanner || tic.dat

 

 

 

 

 

Chapter 8: File I/O lecture

Exceptions: TRY and Catch lecture

file reader reference

Scanner input reference

Handling Exceptions (Try/catch) reference

M 04/12 Games chapters and examples Chapters: 14, 15 and 16
W 04/14

Inheritance (chapter 9)

Inheritance from a super class Example #1:
GeometricObject.txt, Circle.txt, Rectangle.txt, TestCircleRectangle.txt

Inheritance, Review Inheritance

 

Example to show constructor chaining with inheritance : http://www.leepoint.net/notes-java/oop/constructors/q-fi-constructor-chaining.html

 

for more information, see Sun Tutorial

M 04/19

Inheritance (chapter 9)

Inheritance from a super class Example #1:
GeometricObject.txt, Circle.txt, Rectangle.txt, TestCircleRectangle.txt

Polymorphism: Polymorphism Demo

Go over an entire Game (complete TicTacToe during class)

Same class hierarchy with equals() methods and test instanceof operator
GeometricObject.txt, Circle.txt, Rectangle.txt, Cylinder.txt, TestCircleCylinderRectangle.txt


TestCircleCylinderRectangle2.txt (try both Geometric Object files), GeometricObject.txt (with abstract methods)

 

 
W 04/21

Abstract class and Interfaces ( Chapter 11)

 

Reading Chapter 11 (lecture)

review lecture of Abstract class and Interfaces

 

 

 

M 04/26 Interfaces: using Comparable Interface:

Review Sort an array list using comparable interface:

Using ArrayList (data structure) to store objects: TestArrayList example

 

 

 

Review lecture of Abstract class and Interfaces

Interfaces Reference: http://www.leepoint.net/notes-java/oop/interfaces/interfaces.html)

W 04/28

 

Recursion (Study Recursion (cut and paste from lecture for examples)

Final Review and Sample questions

Array Search and Sort examples: Sort and search arrays lecture

 

Array Sort Resources:

Buble Sort example 1 or Buble Sort {visual applet for buble sort]

Section Sort example 1 or Selections Sort {visual applet for Selection sort)

Array Search Resources:

Linear Search example 1 or Linear Search

Binary Search example1 or Binary Search

 

More search and sort methods

 

M 05/03

Final Review and Sample questions

 

 

 

W 5/05

Final Exam -W 5/05 12:00-1:50 PM 101 CIWW