This course is designed for the students who want to learn Java but have 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.
Date | Summary |
---|---|
2018.7.21 | programs, computational solutions, computer systems (CPUs, memory, memory hierarchy), programming languages (high-level, assembly, machine code), algorithms, JDK + Eclipse, first Java program; |
2018.7.22 | variables, data types (int, double, char, boolean) (see IEEE754 standard; also see some disasters attributable to numerical analysis), assignment operator (=), arithmetic operators (+, -, *, /, %), type conversion, casting, rational operators (>, <, ==), logical operators (!, &&, ||, ^), compound operators (+=, ++), reference types, Scanner object; HW0: Lab 0 due 7/28; |
2018.7.28 (3h30m) | selections (if-else if-else, switch-case, ?: operator), loops (while, do-while), for loops; |
2018.7.29 (3h30m) | jump statements, nested loops, analysis of algorithms, arrays; HW1: Lab 1 and 2 due 8/5; |
2018.8.4 | (no class due to regular electricity check) |
2018.8.5 (3h30m) | for-each loops, briefing data structures, sorting algorithms, searching algorithms, higher-dimensional arrays, methods; HW2: Lab 3 due 8/11; |
2018.8.11 (3h30m) | call stack, scope of variable, method overloading, recursion (also read this article; see more examples: ch18-recurex), classes & objects, fields and methods, encapsulation, constructors, this operator, static members, garbage collection, HAS-A relationship (aggregation) (memory and objects), IS-A relationship, inheritance; |
2018.8.12 (3h30m) | method overriding, binding, (subtype) polymorphism, up/down casting, instanceof operator, final variable/method/class, abstract class/method, interfaces, wrapper classes, immutable objects, enum types, namespace, nested classes, anonymous classes, iterators, packages; HW3: Lab 4 and 5 due 8/18; |
2018.8.18 (3h30m) | classpath, JAR, assertion and exception handling, strings, regular expressions (see regex by Oracle, or regexone, regex crossword), file NIO (Chapter 10: File System), events, listeners, callbacks, Java graphics and GUIs, Java event handling, Java 2D games tutorial (see snake game), JavaFX tutorial; |
2018.8.19 | final exam; |
Install JDK 9 and Eclipse (or any IDE you have been familiar with) in your computer (desktop/laptop). The links of both can be found in the slides or this course page (see the installation session). You don't need to send me email for this lab unless you cannot complete the installation.
Let x be any real number. Write a program which calculates the square root of x by using Bisection method. Note that you should reduce this problem to the bisection method with a natural choice for a and b (i.e., the user does not need to provide a and b). Note that Math.pow and Math.sqrt are not allowed.
Write a program for number guessing. The program asks the user to enter an integer from (0, 99). Then the program updates the range depending on the input accordingly. If the input value is equal to the secret number, then the user wins. If there is only one integer left, then the user loses the game. Make sure that the user enters a number in the feasible range. If not, ask the user to redo the input. Send the source code (the file with .java extension) to d00922011@ntu.edu.tw. (Do not attach any class file because any executable file will be ruled out by Gmail.)
Write an AI program which plays this game. For example, the naive strategy is to guess a number in random. Also, calculate the winning rate by simulating your AI program for 1e5 times.
Implement the bubble sort and the insertion sort. Compare the efficiency of these three sorting algorithms (including the selection sort demonstrated in class) by running a Monte Carlo simulation and calculating the timecost of each. Send the source code (the file with .java extension, say homework3.java) to d00922011@ntu.edu.tw. (Do not attach any class file because any executable file will be ruled out by Gmail.)
Let x be any real number and n be any integer (n can be negative). Write a program which calculates x ^ n by recursion. For example, 2 ^ -10 = 0.000976. Try to make your program run in O(log | n |) time. Note that you are not allowed to use Math.pow and any loop in your solution. Send the source code (the file with .java extension) to d00922011@ntu.edu.tw. (Do not attach any class file because any executable file will be ruled out by Gmail.)
Rewrite the program in Lab 2 in object-oriented programming. You may define any number of classes if necessary. Send the source code (the file with .java extension, say homework5.java) to d00922011@ntu.edu.tw. (Do not attach any class file because any executable file will be ruled out by Gmail.)