Java Programming

Location: Room 223B, 德田館
Time: 0930 ~ 1230, from Monday to Friday


``Java is C++ without the guns, knives, and clubs.''
-- James Gosling, co-inventor of Java (1955-)

Goal

This course is designed for the students who want to learn Java without any programming experiences before. We will start with the very beginning of program design and fundamental concepts about programs and machines. You are expected to be capable to implement your idea in Java independently after 30 hours of lectures. Furthermore, I wish you could learn other programming languages without suffering from starting over.

Prerequisites

Text

References

Java (introductory level)

Java (advanced level)

Data structures and algorithms

Object-oriented analysis and design (OOAD)

Related courses

Misc

Additional reading

IDE

Wifi Connection

Overview

Procedural programming

Object-oriented programming

Schedule [ 247, 250, 251, 252, 253, 254, 255, 260, 261, 263, 265, 266, 268, 269, 271, 274 ]

Date Key points and memo Sample code
2016.7.25 program, algorithms, programming languages, binary system, variable, data types; HelloJava.java, ComputeArea.java;
2016.7.26 primitive types (int, double, char, boolean), type conversion, arithmetic operators, rational operators, logical operators, selections (if-else, switch-case, ?: operator), loops (while); ComputeArea2.java, RandomIntegerArithmeticsDemo.java;
2016.7.27 loops (do-while, for), Monte Carlo simulation, bisection method for root finding, nested loops; MonteCarloDemo.java, BisectionDemo.java, IsPrimeDemo.java, MultiplicationTableDemo.java, PrintStarsDemo.java;
2016.7.28 analysis of algorithms, arrays, sorting algorithms, searching algorithms, for-each loops, high-dimensional arrays; ProcessingArraysDemo.java, ShuffleByRedrawDemo.java;
2016.7.29 methods, call stack, variable scopes, method overloading, recursion, class & object, fields and methods, encapsulation, constructors; feedback; MethodDemo.java, FactorialDemo.java, FibDemo.java, RPGdemo.java;
2016.8.1 this operator, static members, HAS-A relationship (aggregation and composition), IS-A relationship, inheritance, method overriding, (subtype) polymorphism, up/down casting, binding; PointDemo.java;
2016.8.2 final, abstract class, interfaces, default methods, package, nested classes, classpath, JAR; WrapperClassDemo.java, EnumDemo.java, Maze.zip;
2016.8.3 exception handling, file I/O, GUI design, event handling; ExceptionHandlingDemo.java, firstGUI.java;
2016.8.4 list, Arraylist, linked list, stack and queue, generics, generics (detailed), multithreading, networking programming; java-rpg;
2016.8.5 final exam (Calculator.java); Problem1.java, Problem2.java, Problem3.java, Problem4.java;

Homework

Write a program for Bulls and Cows (猜數字/終極密碼). The program first generates a random integer as the secret number s. For simplicity, assume that 1 <= s <= 100. Also, x denotes the input from the player. Then the program takes x and reports a updated range repeatedly until x == s. Note that the range should shrink monotonically because the player is limited to answer an integer within the range. If there is one integer left in the range, then the player loses the game. For example,

Gradebook