Open main menu

CDOT Wiki β

Changes

User:Qinzhi

1,446 bytes added, 00:34, 3 February 2011
no edit summary
In the left side of Eclipse, that is the package explorer.
Use mouse to expend cs.ecl.basics.simple, I can see src and JRE System Library.
4. Editing Java element I clicked Library.java and added following code: @Override public String toString() { return "Library [resources=" + resources + "]"; } 5. Creating a Java class
In package explorer, right click on src folder, and select new->class,
type student, and click enter key.
I changed Video.java to Audio.java by changing the interface name.
7. Moving and copying Java elements
I copied Audio.java and paste it in the project, and changed name to Video, then Video.java is created.
If I use mouse to move Video.java to Media.java, it's the same as copying.
8. Navigate to a Java element's declaration
I changed the value of name_1 to DVD. Then DVD.java is created.
15.Using the Java browsing perspective
In menu, select Window->Open perspective->Java browsing.
A new windows arrangement shows:
The top 4 windows are projects, packages, types and members.
The bottom window is the program window.
I can drag what I want from types and members to the bottom window.
It's very convenience for programming.
16.Writing and running JUnit tests
Since the package cs.ecl.basics.simple is already include test folder.
Also it includes testAddMedia() and testRetrieveLast() functions.
I clicked run, it shows 2 errors:
@Test
public void testAddMedia() {
fail("Not yet implemented");
}
@Test
public void testRetrieveLast() {
fail("Not yet implemented");
}
I changed to following:
package cs.ecl.basics.simple.example1;
import junit.framework.Assert;
import org.junit.Test;
public class LibraryTest {
Library<DVD> Ld = new Library<DVD>();
@Test
public void testAddMedia() {
DVD d = null;
Ld.addMedia(d);
}
@Test
public void testRetrieveLast() {
Assert.assertEquals(null,Ld.retrieveLast());
}
}
The program runs correctly.
Assert.asserEquals is a function to check 2 parameters are equal or not.
End.
1
edit