静态博客入口:http://blog.5d.cn/user3/isaiah/
2007/01/13 | tossCoin
类别(STUDY) | 评论(0) | 阅读(43) | 发表于 16:24

/**Toss coin test that allow the you guess the upside as many times as you wish. When exit, the system would give you a list of information about your guesses.*/
import java.io.*;
public class TossCoin {
 public static void main(String[]args)
 {
  String input=null;
  long seed=System.currentTimeMill

...
2007/01/11 | 接口类继承问题
类别(STUDY) | 评论(0) | 阅读(48) | 发表于 16:01

接口类只可以继承接口类的,例如Student是一个类,而“public interface CollegeStudentInterface extends Student”就是错误的。如果要写一个CollegeStudent的接口只能先把Student接口化,然后将CollegeStudentInterface继承它。

/**An interface for a class of students.*/
public interface StudentInterface
{
 /**

...
2007/01/09 | GenericCoin
类别(STUDY) | 评论(0) | 阅读(23) | 发表于 18:39

·实验说明:模拟一个银币,此银币有两个面。方法为‘抛银币’,银币顶面、底面随机向上。抛两银币各50次,并显示两银币顶面向上次数和哪个银币顶面次数较多。

·代码:

import java.util.*;
public class GenericCoin {
 private int front;
 private int back;
 
 GenericCoin(){ 
  front=1;
  back=0;
 }//end constructor
 
 

...
2007/01/06 | Person
类别(STUDY) | 评论(0) | 阅读(21) | 发表于 17:16

/** a person with name and age*/
public class Person {
 private Name name;
 private int age;
 
 public Person(){
  name=null;
  age=0;
 }//end default constructor
 
 public Person(Name personName,int personAg

...
2007/01/03 | Student
类别(STUDY) | 评论(0) | 阅读(23) | 发表于 16:53

·实验说明:创建了Student类,数据域中声明了类型为一个先前创建的Name类的私有变量。main方法中使用两种创建Student对象的方法。

·代码
public class Student {
   private Name fullName;
   private String id;//学号
  
   public Student(){
    fullName=new Name();
    id="";

...
2007/01/03 | Name
类别(STUDY) | 评论(0) | 阅读(13) | 发表于 16:42

·实验说明:创建Name类,构造两个Name对象,并把第一个对象的第一姓名赋予第二个对象。打印相应结果。

·代码
public class Name {
   private String first; //名
   private String last;  //姓

   public Name(){
   
   }//end default constructor
  
   public Name(String firstName, String lastN

...
2007/01/01 | Java.study.Counter
类别(STUDY) | 评论(0) | 阅读(34) | 发表于 11:19

· 实验

·作用:计数器,实现每次加一或减一运算

·代码:
public class Counter {
//post:increase or decrease cnt by 1
private int cnt;
public Counter(){
 cnt=0;
}//end default constructor
public void inc(){
 ++cnt;
}//end inc 
public void dec(){

...
日志分类
首页[90]
GUITAR[43]
JRUM[4]
PIANO[23]
HEART_ACHES[5]
STUDY[7]
FRAGMENT[8]