2009年4月17日 星期五

Lab Firefox Accessibility Extension

Use Firefox Accessibility Extension to check the accessibility of three sites that you visit most.
Report the summary of all the errors and warnings for each site.


中原大學:http://itouch.cycu.edu.tw/

阿榮福利味:http://azo-freeware.blogspot.com/

google:http://www.google.com.tw

2009年4月13日 星期一

LAB


public class Fraction {
private int numerator;
private int denominator;

public void number( int numerator, int denominator)
{
this.numerator = numerator; //把這method的區域變數numerator給予這個類別內宣告的numerator
this.denominator = denominator; //this:代表使用中的類別,也可以使用在變數名稱有重複或易於混淆時
}
public String outputstring() {

return (numerator + "/" + denominator);  //分數的表示形式
}


public boolean equal(Fraction Fraction2)
{
if(numerator*Fraction2.denominator == denominator*Fraction2.numerator)
{
return true;
}
else
{
return false;
}
}

public static void main(String[] args) 
{
Fraction f1 = new Fraction();
Fraction f2 = new Fraction();
f1.number(1, 2);
f2.number(2, 4);
System.out.println("f1 = " + f1.outputstring() + "\nf2 = " + f2.outputstring());
//System.out.println("f1 + f2 = "+ f1.add(f2).outputstring());
System.out.println(f1.equal(f2));
}


}


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


public class Fraction {
private int numerator;
private int denominator;

public void number( int numerator, int denominator)
{
this.numerator = numerator; //把這method的區域變數numerator給予這個類別內宣告的numerator
this.denominator = denominator; //this:代表使用中的類別,也可以使用在變數名稱有重複或易於混淆時
}
public String outputstring() {

return (numerator + "/" + denominator);  //分數的表示形式
}

public Fraction add(Fraction Fraction2) //add中有2個Fraction相加,Fraction Fraction2
{                                       //為Fraction.add(Fraction)表示方式並為區隔而寫為Fraction2
Fraction countOfTemp = new Fraction();
countOfTemp.numerator = numerator*Fraction2.denominator + denominator*Fraction2.numerator;
countOfTemp.denominator = denominator*Fraction2.denominator;
//交叉相乘
return countOfTemp; 
}


public static void main(String[] args) 
{
Fraction f1 = new Fraction();
Fraction f2 = new Fraction();
f1.number(1, 2);
f2.number(1, 3);
System.out.println("f1 = " + f1.outputstring() + "\nf2 = " + f2.outputstring());
System.out.println("f1 + f2 = "+ f1.add(f2).outputstring());
 
}


}


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);


2009年4月12日 星期日

Homework 3-30-2009: 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

/*
* Counter.java
*
* Created on 2009年4月12日, 下午 11:01
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package javaapplication16;

/**
*
* @author KFN
*/
public class Counter {
private int counter;

void reset()
{
counter = 0;
}

void inc()
{
++counter;
}

void dec()
{
--counter;
}

int getcounter()
{
return counter;
}

void output()
{
System.out.println(counter);
}
/** Creates a new instance of Counter */
public Counter() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Counter counter = new Counter();

counter.reset();
counter.inc();
counter.inc();
counter.inc(); //作為測試多做了2個加
counter.inc();
counter.dec();
counter.output();
// TODO code application logic here
}

}