![]() |
public
String movieedit(String[] args){//to edit movie record of Movie_Show_Time
table int id=0; String message=""; String retvalue = args[0]; String retvalue2 = args[0]; String retvalue3 = args[0]; StringBuffer hold = new StringBuffer(); StringBuffer hold2 = new StringBuffer(); StringBuffer hold3 = new StringBuffer(); int ind,ind2,ind3; char c; ind=retvalue.indexOf ("Time:"); ind2=retvalue.indexOf ("Date:"); ind3=retvalue.indexOf ("Price:"); for ( int i = 0; i < retvalue.length(); i++ ) { //1 if ( (c=retvalue.charAt(i)) != ',' ) //2 hold.append(c); //3 else break; //4 } retvalue = hold.toString(); //5 for ( int i = ind+5; i <ind2-1; i++ ) { //6 if ( (c=retvalue2.charAt(i)) != '-' ){ //7 hold2.append(c); //8 } else break; //9 } retvalue2 = hold2.toString(); //10 for ( int i = ind2+5; i <ind3-1; i++ ) { //11 c=retvalue3.charAt(i); hold3.append(c); //12 } retvalue3 = hold3.toString(); //13 try{ //to edit Movie_Show_Time price,start and end time rs=getResult("SELECT * FROM Movie_Record WHERE (Title ='"+retvalue+"')"); rs.next(); id=rs.getInt("Movie_ID"); recUpdate("UPDATE Movie_Show_Time SET Price ="+ args[1]+",Start_Time_Slot ='" +args[2]+"',End_Time_Slots ='"+args[3]+"' WHERE Movie_ID ="+id+" AND Start_Time_Slot = #" +retvalue2+"# AND Date_Slots = #" +retvalue3 +"#"); message="The record with ID "+id+" has changed. Price:$"+args[1]+" Start time: "+args[2] +"hrs. Endtime: "+args[3]+"hrs"; } //14 catch (Exception e){ return message; a } // end catch return message; //15 } |
Test cases
Test case (1): for Path 6
Variable values: i==retvalue.length() && c == ¡®-¡® && c == ¡¯,¡¯
Expected values:
No changes are made as there¡¯s no input (check validity)
Test case (2): for Path 4
Variable values: I <retvalue.length() && c!= ¡®-¡® && c!=¡¯,¡¯
Expected values:
(1) Movie time, date and price are changed according to the input from the administrator
(2) Message with changes will also be presented
Note: for this test though there are 6 paths, but only
several paths really test the functionality of the method. For path 6 is about
whether changes will still carry out even though there is no input. For path
4 is about whether changes will be carried out if there are inputs.