2008年12月29日 星期一

我有話要說

本來選這堂課的用意,是因為JAVA可以運用在網頁及程式,對於以後要走的路算是很有幫助。這堂課一開始從基本的算術教起,一開始並不覺得難,反而覺得很有意思。
但是後來到了偏物件導向的部分,開始就有些挫折 因為沒有使用過類似的寫法,很多部分還是以C++的方式去寫。
老師上課有提醒我們寫JAVA時,應該注意哪些細節,如果以後想當工程師的話,是不允許這些錯誤的!!

第一次小考,考了60。
我覺得考得並不理想,幾乎都是對課本的題目,程式有些有寫出來。但是當老師公布答案時,我還蠻驚訝,因為我寫得很複雜,但是答案其實僅有短短幾行,可能是我沒有翻前幾年的題目來練習。

學習當中,發現設計java的class確實不容易,我在寫作業時,常會問我的逢甲資工系同學,雖然他看到我寫的程式,只有搖搖頭。不過他還是鼓勵我先完成它。然後真的寫不出來再去問他。平常會逛逛JAVA網站,像是JAVAWORLD,去看看別人是怎樣寫的,跟自己寫的程式差異在哪?在逛JAVA網站時有看到一句話,我覺得很有幫助。「當你寫java程序寫到一半卻發現自己用的方法很拙劣時,請不要馬上停手;請盡快將餘下的部分粗略的完成以保證這個設計的完整性,然後分析自己的錯誤並重新設計和編寫。」
所以每當我又學到新的知識,就會回去看看自己以前寫過的程序,並嘗試重寫,而且當完成之後,我自己會有很大的成就感!就會很感謝老師在上課時,把每個基本用法都講得很清楚,很感謝老師的指導,在這學期真的學到很多。

2008年12月19日 星期五

Lab Hanoi Tower


The pseudocode for Hanoi Tower is as follows:
solve(N, Src, Aux, Dst)
if N is 0 return
solve(N-1, Src, Dst, Aux)Move N from Src to Dstsolve(N-1, Aux, Src, Dst)
Write the Java program based on the pseudocode in the above.

Lab Factorial


Lab Recursive Method


2008年12月18日 星期四

2008年12月13日 星期六

2008年12月12日 星期五

Lab Overloading




2008年11月28日 星期五

Lab ADT

Define a Complex class and write an object oriented program to compute (2+3i)+(4+5i) in Java.The methods should include an access and a mutator.

lab Fraction equality test

Write a program to implement a method that can check whether 2 fractions are equal. You will implement a class called Fraction consisting of a numerator and a denominator. The equality test of 2 fractions should return a boolean value.

Use the following as the tests.

  • 1/2, 2/4
  • 5/6, 6/7

Hints:
Fraction f1, f2;
f1.equals(f2);





































lab Fraction Addition

Write a program to implement a method that can do additions of 2 fractions. You will implement a class called Fraction consisting of a numerator and a denominator. The additions of
2 fractions should be equal to a fraction.
Use 1/2+1/3 as the test.

Hints:
Fraction f1, f2;
f1.add(f2);






















2008年11月21日 星期五

2008年11月7日 星期五

lab counter

Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Include an accessor method that returns the current count value and a method that outputs the count to the screen. Write a program to test


counter.reset();
counter.inc();
counter.inc();
counter.dec();
counter.output();






Homework 10-31-2008




2008年10月30日 星期四

2008年10月29日 星期三

Homework 10-24-2008

1.費氏數列





























2.九九乘法






2008年10月24日 星期五

2008年10月23日 星期四

2008年10月19日 星期日

Homework 10-3-2008

Project 4 in Chapter 2




Project 5 in Chapter 2



Project 6 in Chapter 2





Project 7 in Chapter 2







Lab: Numerical Method


2008年10月3日 星期五

Lab Keyboad processing

Lab Keyboard Input

Rewrite Display 2.6 using BufferedReader.

You need to import the following packages in the first place.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

Change

Scanner keyboard= new Scanner(System.in);

into

BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));

String inputString = keyboard.readLine();

Note the Main method needs IOException handling as follows:

public static void main (String[] args) throws IOException

Lab Scanner

2008年9月28日 星期日

Homework 9-26-2008

1. Complete Lab String Processing.




2. Write a program that can reverse the order of an input string. For example, if you input "ab", it will output "ba". If you input "abcdefg", it should return "gfedcba".


個人對上句的解釋是 輸入什麼字串就反轉什麼字串




ex:



input : java

output : avaj


2008年9月26日 星期五

2008年9月25日 星期四

homework1

1. Explain bytecode, JVM

The java compiler translates your program into a language called byte-code,which is the machine language for a fictitious computer.It is easy to translate this byte-code into the machine language of any particular computer.Each type of computer will have its own interpreter that translates and executes byte-code instructions.Byte-code is the machine language for a fictitious computer called the Java Virtual Machine.

Byte-code is the machine language for a fictitious computer called the Java Virtual Machine.
2. Explain class, object
A java program works by having things called objects perform actions. The actions are known as methods and typically involve data contained in the objects. All objects of the same kind are said to be of the same class .
A class is a category of objects.

class 是類別.object 是特性

3. Reading Assignments:Read 1.1, 1.2, 1.3 of Textbook

4.1 Write a Java program as follows:
Let i=2;

Print i;

Print 2 * (i++);
Print i;





4.2 Write a Java program as follows:
Let i=2;
Print i;
Print 2 * (++i);
Print i;





4.3 Write a Java program as follows:
Let m=7, n=2;
Print (double) m/n;

Print m/ (double)n;


2008年9月19日 星期五

2008年9月12日 星期五

9526255

我是電子三乙55號許志豪

歡迎大家來我網誌參觀