# Desperate for some help if possible :(

• 11-30-2010, 07:55 PM
SBOSlayer
Desperate for some help if possible :(
Hey all I was wondering if someone could help me understand this code as It will unlock my ability to pass this exam tomorrow... I was good at java and now i'm totally out of date as i've barely touched it in years since I completed my HND. Anyways, I was wondering if someone could help explain this code to me? It would be so much appreciated

public class TimeTest extends TestCase {
public void testValidConvert24to12hour() {
String[] times = {"0000","1200","0300","0650","1059","2159","2359"} ;
String[] timeStrings = {"12:00am","12:00pm","3:00am","6:50am",
"10:59am","9:59pm","11:59pm"};
Time test = new Time();
for (int x=0;x<times.length;x++){
String result = test.convert24to12hour(times[x]);
assertEquals("Test time "+x,timeStrings[x],result);
}
}
public void testInvalidConvert24to12hour() {
String[] times = {"12309","650","2450","1360","0675","x650","1Q5 0",
"16Z0","165K"};
Time test = new Time();
for (int x=0;x<times.length;x++){
String result = test.convert24to12hour(times[x]);
assertNull("Test time "+x,result);
}
}
}

I don't actually understand where the Time test = New time Comes from.. also where the x++ is coming from. IT's very stressful as I am very unsure of this code. Is there anyway to locate it in the IDE Netbeans interface so i know what i'm linking too? This is the solution, but I am not understanding the location of this. Everything else is pretty basic to me apart form this.