Courses‎ > ‎AP Computer Science 2‎ > ‎Konstantinovich‎ > ‎

2017-05-31 Lab results

posted May 31, 2017, 7:05 AM by Samuel Konstantinovich   [ updated May 31, 2017, 7:35 AM ]
You already got drivers for 7,8. Here are drivers for 10,11. 

Test10.java  
usage:  (where n is 0-5) 
java Test10 n  

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.*;
public class Test10{

  public static void testException(String name,int size){
    MyDeque base = new MyDeque();
    for(int i =0; i < size; i++){
      base.addFirst(""+i);
    }
    boolean result = true;
    for(int i =0; i < size && result; i++){
      result = result && base.removeLast().equals(""+i);
    }
    String message = "";

    if(result){
      try{
        base.removeLast();

         message = "FAIL Emptying case (No EXCEPTION THROWN): "+name;
      }catch(NoSuchElementException e){
        message = "Passed emptying case: "+name;

      }
    }else
    {
      message = "FAIL Emptying case (VALUE ERROR): "+name;
    }
   System.out.println( message);
  }
  public static void testCreation(String name,int size){
    ArrayDeque<String>d = new ArrayDeque<String>(size);
    MyDeque base = new MyDeque();
    long start = System.currentTimeMillis();
    for(int i = 0,j = 0; i < size/2; i++,j+=3){
      d.addFirst(""+i);
      base.addFirst(""+i);
      d.addLast(""+j);
      base.addLast(""+j);
    }
    String[]check = new String[size];
    int index = 0;
    while(index<size){
      check[index] = base.removeFirst();
      index++;
    }
    long end = System.currentTimeMillis() - start;

    if(Arrays.equals(d.toArray(),check)){
      System.out.println("Passed case: "+name+" in "+end/1000.0+" seconds.");
    }else{
      System.out.println("\tFAIL CREATION case: "+name +".");
    }

  }

  public static void main(String[]args){
        int testNum = new Integer(args[0]);
        if(testNum>=0 && testNum <4){
          testCreation(args[0],new Integer(args[1]));
        }
        if(testNum>=4 && testNum <6){
          testException(args[0],new Integer(args[1]));
        }

  }
}

Test11.java  
usage:  
java Test11 

public class Test11{

    public static void main(final String[] args) {
      int count=0;
      if(StackCalc.eval("0")==0.0){
        count++;
      }
      if(StackCalc.eval("-5")==-5.0){count++;}
      if(StackCalc.eval("20 3 +")==23.0){count++;}
      if(StackCalc.eval("108 212 + 525 -")==-205.0){count++;}
      if(StackCalc.eval("47 969 / 0 - 769 -")==-768.9514963880289){count++;}
      if(StackCalc.eval("15 443 * 336 * 939 / 600 -")==1777.7635782747602){count++;}
      if(StackCalc.eval("67 128 - 297 469 * + 354 + 66 - 345 - 732 -")
          == 138443.0){
            count++;
      }
      if(StackCalc.eval("670 150 511 / + 836 717 * 261 / + 60 - 851 +")==3757.8912432237894){
          count++;
      }
      System.out.println("SCORE out of 8 : " + count);
    }

}



OSIS1256781011
205312234902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
205324502702: 11 / 112006: 7 / 77136SCORE of 8 : 8 
20556927062: ---006: 4 / 77: ---8: ---10: ---11: ---
205756174902: 11 / 112006: 7 / 71213111: ---
206016958902: 10 / 1106: ---7: ---8: ---10: ---11: ---
206119901902: 11 / 111506: 7 / 7101310: ---SCORE of 8 : 8 
206174740902: 11 / 112006: 7 / 713132SCORE of 8 : 8 
206298812902: 11 / 11006: 7 / 713131SCORE of 8 : 3 
206385445902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
206779092902: 11 / 112006: 0 / 713120SCORE of 8 : 8 
206836678602: 11 / 112006: 6 / 77: ---131SCORE of 8 : 8 
20701107372: ---1006: 7 / 7111310: ---11: ---
207150723902: 11 / 112006: 7 / 7131310: ---SCORE of 8 : 8 
207175431902: 11 / 11006: 7 / 788: ---10: ---SCORE of 8 : 8 
207185661902: 11 / 112006: 6 / 713126SCORE of 8 : 8 
207186479902: 11 / 112006: 0 / 713136SCORE of 8 : 3 
207193376902: 11 / 112006: 7 / 7131310: ---SCORE of 8 : 8 
207198813902: 11 / 112006: 7 / 7131310: ---SCORE of 8 : 8 
207204637902: 11 / 111706: 7 / 710136SCORE of 8 : 8 
207234352802: 11 / 112006: 7 / 71313611: ---
207257510902: 11 / 112006: 7 / 713121SCORE of 8 : 8 
207268863902: 11 / 111006: 2 / 713134SCORE of 8 : 5 
207354838902: 11 / 112006: 7 / 77: ---136SCORE of 8 : 8 
207371998902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
207374091902: 9 / 11006: 7 / 77: ---124SCORE of 8 : 8 
207374547902: 11 / 112069930 is HUUUUGE OUTPUT!7: ---8: ---10: ---SCORE of 8 : 8 
20739127792: ---006: 7 / 77: ---8: ---10: ---11: ---
207423799802: 11 / 112006: 7 / 77: ---1210: ---SCORE of 8 : 8 
207438474902: 11 / 112006: 2 / 71313611: ---
207474545902: 11 / 114108 is HUUUUGE OUTPUT!06: 7 / 7312111: ---
2075375561: ---2: ---006: 0 / 77: ---1310: ---11: ---
207677840902: 11 / 111912120SCORE of 8 : 8 
207691148902: 11 / 112006: 7 / 7131310: ---11: ---
207700485902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
207723016902: 11 / 112006: 0 / 77130SCORE of 8 : 8 
207723230902: 11 / 1106: ---7: ---8: ---10: ---11: ---
207781790902: 11 / 112006: 0 / 7131210: ---SCORE of 8 : 8 
207782087886: ---330incorrect input 
207782368802: 11 / 111806: 7 / 713134SCORE of 8 : 8 
207915497902: 11 / 111806: 7 / 77: ---0611: ---
207979568902: 11 / 112006: 7 / 713120SCORE of 8 : 8 
208084780902: 11 / 111906: 7 / 71313011: ---
208087569902: 11 / 111806: 7 / 7131310: ---SCORE of 8 : 8 
208185835902: 11 / 112006: 7 / 713130SCORE of 8 : 8 
208248807802: 11 / 112006: 7 / 71311SCORE of 8 : 8 
208254029902: 11 / 11006: 7 / 71410: ---11: ---
208337451902: 11 / 112006: 7 / 712131SCORE of 8 : 8 
208365999802: 10 / 112006: 7 / 7100331 is HUUUUGE OUTPUT!1310: ---SCORE of 8 : 8 
208377580902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
208394692902: 11 / 11006: 7 / 713126SCORE of 8 : 8 
208408385902: 11 / 112006: 7 / 712136SCORE of 8 : 8 
208434720902: 11 / 112006: 2 / 713130SCORE of 8 : 8 
20846581582: ---06: ---7: ---8: ---10: ---11: ---
208512509902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
208512699902: 11 / 112006: 7 / 77: ---70SCORE of 8 : 8 
208584086902: 11 / 112006: 7 / 713126SCORE of 8 : 8 
208627539902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
208667436902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
208670125902: 11 / 112006: 7 / 7131310: ---11: ---
208744193902: 11 / 112006: 7 / 7131310: ---SCORE of 8 : 5 
208845016902: 11 / 111906: 7 / 713136SCORE of 8 : 8 
20889988092: ---126: ---13136SCORE of 8 : 8 
208908293902: 11 / 112006: 2 / 71313011: ---
208908533902: 11 / 112006: 7 / 712126SCORE of 8 : 8 
208947739902: 11 / 111606: 7 / 713131SCORE of 8 : 8 
20897984992: ---2006: 7 / 7131310: ---SCORE of 8 : 5 
209005677902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
209033166902: 11 / 111706: 7 / 710134SCORE of 8 : 8 
209064732902: 11 / 112006: 7 / 713134SCORE of 8 : 8 
209267145902: 11 / 112006: 7 / 7131310: ---11: ---
20926828392: ---006: 7 / 77: ---110: ---11: ---
209475722902: 10 / 111806: 7 / 712121SCORE of 8 : 3 
209517523902: 11 / 112006: 6 / 713121081 is HUUUUGE OUTPUT!SCORE of 8 : 8 
214708794902: 11 / 11006: 0 / 77: ---8: ---10: ---11: ---
214717522902: 11 / 112006: 7 / 7131310: ---11: ---
215386194902: 11 / 112006: 7 / 7131310: ---SCORE of 8 : 8 
216000083902: 11 / 112006: 7 / 7131310: ---SCORE of 8 : 7 
216085423902: 11 / 112006: 0 / 7131310: ---SCORE of 8 : 8 
2164112071: ---02: 11 / 11106: ---128: ---10: ---11: ---
217774520902: 11 / 112006: 2 / 713134SCORE of 8 : 8 
220874002802: 10 / 112006: 7 / 7121310: ---SCORE of 8 : 8 
222491128902: 11 / 112006: 7 / 71131SCORE of 8 : 7 
226107795902: 11 / 111006: 7 / 71212111: ---
229080502902: 11 / 111906: 7 / 713134SCORE of 8 : 8 
2319108861: ---02: 11 / 112006: 7 / 71312611: ---
23314888192: ---2006: 7 / 713134SCORE of 8 : 8 
233149079902: 11 / 111806: 7 / 71213111: ---
236029385902: 11 / 112006: 7 / 77: ---8: ---10: ---11: ---
236053138902: 11 / 112006: 7 / 713136SCORE of 8 : 8 
236072427902: 11 / 112006: 7 / 713110: ---11: ---
23607546192: ---2006: 7 / 7131210: ---SCORE of 8 : 8 
236586327902: 11 / 112006: 7 / 713134SCORE of 8 : 8 
237060256902: 11 / 111906: 7 / 713130SCORE of 8 : 3 
Comments