偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

利用BlueJ對程序進行測試

開發(fā) 后端
BlueJ是由英國肯特大學,澳大利亞蒙納什大學與太陽公司(Sun)合作開發(fā)的一個完整的JAVA編譯調(diào)試環(huán)境,特別適合JAVA教學和介紹。它支持:完整的圖形化的類構建;文本和圖形編輯器;虛擬機和debug等。它由簡單易用的界面,由適合初學者的交互式對象構建和調(diào)用等等,是學習JAVA的好工具!

bluej 可以不寫main函數(shù),就對程序進行操作非常簡單的測試。

簡單功能如何:

首先,在以前,我們對自己所寫的程序測試,需要如下操作:

 

 

在main函數(shù)中,有對各種對StuClass方法測試的代碼。

而如今,我們可以省去main函數(shù)的大量書寫,通過另外一種方法更加快捷地對程序進行測試:

 

 

操作之后,在bluej界面左下角,出現(xiàn):

 

 

紅色顯示的區(qū)域即為 類的 一個實例,右擊之后,可以對其方法進行測試,如:void addStu(String name), 并且可以通過 Inspect 對實例的變量進行測試,觀察。

注意:

1.private方法 不會顯示出來,因為 類的對象不能對 類的private方法進行調(diào)用。

如果構造函數(shù)被private修飾,則不能通過此方法進行測試,因為被private修飾后,只有類的內(nèi)部可以使用。

2.用static修飾的變量,不需要創(chuàng)建實例,而直接右鍵點擊類,進行觀察,因為在是類的變量。

3.用static修飾的方法,同樣不需要創(chuàng)建實例,直接右鍵點擊類,可以進行調(diào)用,如果語句:Student.createStudent(name);因為是類的方法。

下面,附上代碼:

Java代碼

 

  1. public class StuClass     
  2. {     
  3.     private Student[] stus;     
  4.     private int number;     
  5.          
  6.     public StuClass()     
  7.     {     
  8.         stus = new Student[50];     
  9.         number = 0;     
  10.     }     
  11.          
  12.     public void addStu(String name)     
  13.     {     
  14.         stus[number] = Student.createStudent(name);     
  15.         number ++;     
  16.     }     
  17.          
  18. }     
  19.     
  20.     
  21.     
  22. public class Student     
  23. {     
  24.     private String stuNum;     
  25.     private String name;     
  26.     private static int num = 0;     
  27.          
  28.     public static Student createStudent(String name)     
  29.     {     
  30.         String stuNum;     
  31.         String numString;     
  32.         num ++;     
  33.         if (num < 10) numString = "00" + num;     
  34.         else if (num < 100) numString = "0" + num;     
  35.         else numString = "" + num;     
  36.         stuNum = "JB09" + numString;     
  37.              
  38.         return new Student(stuNum, name);           
  39.     }     
  40.          
  41.     private Student(String stuNum, String name)     
  42.     {     
  43.         this.stuNum = stuNum;     
  44.         this.name = name;     
  45.     }     
  46.     
  47.         
  48. }     

//以下是課堂的筆記:

//1.stuNum should be created by CLASS_Student(it's okay that CLASS_StuClass arrange the stuNum, but stuNum is the attribute of student, it's better to create stuNum in CLASS_Student.)

//2.avoid the mistake made by OBJECT_StuClass(if delete the method createStudent, then the constructor can be public, but if CLASS_StuClass' OBJECT have wrong operation, stuNum may wrong,too).

【編輯推薦】

  1. Eclipse插件終極攻略:測試插件
  2. Eclipse插件終極攻略:基本概念介紹
  3. Eclipse插件大全 挑選最牛的TOP30
  4. Jython開發(fā)的JUnit測試包
責任編輯:金賀 來源: JavaEye博客
相關推薦

2009-04-21 11:02:54

Rational.NET建模

2022-01-10 07:17:02

安全工具CFB模糊測試

2015-06-15 11:45:55

2011-11-17 16:45:33

AdobeAIRWidget

2013-04-23 09:38:39

2011-08-22 09:59:16

2010-02-23 13:33:49

Python測試套件

2013-05-24 09:25:27

2011-03-15 14:36:04

MyisamchkMySQL數(shù)據(jù)表

2010-12-27 09:19:23

2021-03-13 17:49:56

網(wǎng)站測試Web程序開發(fā)

2021-01-05 08:00:00

Windows 10工具GPU

2012-11-01 11:32:23

IBMdw

2012-11-01 11:37:05

JavaScript單元測試測試工具

2013-03-11 18:04:02

2017-07-19 13:40:42

卷積自編碼器降噪

2010-01-15 17:18:57

C++源程序

2010-02-07 10:21:27

Android應用程序

2010-02-22 15:49:35

Python應用程序

2023-06-06 16:10:11

點贊
收藏

51CTO技術棧公眾號