Assignment 4, due Feb 8
Part of
the homework for CS:2820, Spring 2019
|
Assignments are to be turned in on paper. On every assignment, write your name, course and section number at the top of each page. Write your name as it appears in your university records! Use the section number for which you are registered! We will not do detective work to figure out who did what. Work must be legible.
Homework is due on paper in discussion section, usually at the start except when the assignment indicates that time to work on the assignment will be provided in class. Exceptions will be made only by advance arrangement with your TA (excepting "acts of God" outside your control). Never push homework under someone's door!
String s = "something"; for ( int i = 0; i < s.length(); i++ ) { system.out.print( s.charAt( i ) ); }
a) Rewrite this as a while loop, still using an integer control variable. (0.5 points)
b) Rewrite this using a while loop, but using class StringCharacterIterator to deliver consecutive characters of the string. (0.5 points)
Note: Class StringCharacterIterator is a wretched class that ought to correspond in some way to Iterator <Character> but isn't even vaguely compatible.
Assuming that your solution to MP2 will process an input file looking something like this:
gate a xor 6.7 gate b threshold 1 3.6 wire a 3.2 b wire b 1.5 a 1.8 a
Wires must contain at least one destination but may contain more, each preceeded by the delay from the source. Gates must have a delay, and threshold gates have a threshold given before the delay. Of course, the input file must be given on the command line, and it must be possible to open it.
A problem: Given what you know about MP1 and what you can guess about your solution to MP2, what is the minimum number of distinct test runs required to do path testing on the program. Give a very brief justification for each run, showing the parameters you would provide when you launch the program and the test file, if any. (1.0 point)
Note: A fully developed path test suite can only be developed after you write the code, but this problem asks you to start designing some appropriate tests before you have any code, in keeping with the extreme programming philosophy of developing tests before writing code. With no code, you can try to work on testing all the ways you could make an error in the input text.