diff --git a/CodeTestHelper.java b/CodeTestHelper.java index ced024207..0b338de61 100644 --- a/CodeTestHelper.java +++ b/CodeTestHelper.java @@ -52,11 +52,12 @@ public CodeTestHelper(String name) { public CodeTestHelper(String name, String input){ inContent = new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)); + InputStream temp = System.in; System.setIn(inContent); setupClass(name); - System.setIn(System.in); + System.setIn(temp); } @@ -1483,13 +1484,15 @@ public boolean containsMatch(String orig, String target) { public String getMethodOutputWithInput(String methodName, String input) { inContent = new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)); + InputStream temp = System.in; + System.setIn(inContent); String output = getMethodOutput(methodName); - System.setIn(System.in); + System.setIn(temp); return output; } -} \ No newline at end of file +} diff --git a/_sources/MixedFreeResponse/RandomStringChooserParsonsA.rst b/_sources/MixedFreeResponse/RandomStringChooserParsonsA.rst index b7ce4b76a..aedeb6d98 100755 --- a/_sources/MixedFreeResponse/RandomStringChooserParsonsA.rst +++ b/_sources/MixedFreeResponse/RandomStringChooserParsonsA.rst @@ -39,7 +39,7 @@ Mixed Up Code Practice :adaptive: :noindent: - The mixed up code below includes the correct code for the class, a field, a constructor, and the getNext method. In the constructor it will create an ArrayList and fill it by looping through the array and adding each string to the list. In the getNext method, if the list length is greater than zero, it will pick a position at random in the list and remove the item from that position and return it. Otherwise, if the list is empty, it returns "NONE". The blocks have been mixed up and include extra blocks that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The mixed up code below includes the correct code for the class, a field, a constructor, and the ``getNext`` method. In the constructor it will create an ``ArrayList`` and fill it by looping through the array and adding each string to the list. In the ``getNext`` method, if the list length is greater than zero, it will pick a position at random in the list and remove the item from that position and return it. Otherwise, if the list is empty, it returns "NONE". The blocks have been mixed up and include extra blocks that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class RandomStringChooser { @@ -95,7 +95,7 @@ More Mixed Up Code Practice :adaptive: :noindent: - The mixed up code below includes the correct code for the class, a field, a constructor, and the getNext method. In the constructor it will create an ArrayList and fill it by looping through the array and adding each string to the list. In getNext it will return "NONE" if the length of the list is 0. Otherwise, it will calculate a random index in the list, remove the string at that index, and return it. The blocks have been mixed up and include extra blocks that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The mixed up code below includes the correct code for the class, a field, a constructor, and the ``getNext`` method. In the constructor it will create an ``ArrayList`` and fill it by looping through the array and adding each string to the list. In ``getNext`` it will return "NONE" if the length of the list is 0. Otherwise, it will calculate a random index in the list, remove the string at that index, and return it. The blocks have been mixed up and include extra blocks that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class RandomStringChooser { diff --git a/_sources/MixedFreeResponse/RandomStringChooserParsonsB.rst b/_sources/MixedFreeResponse/RandomStringChooserParsonsB.rst index 36d8d1ed7..e692d268b 100755 --- a/_sources/MixedFreeResponse/RandomStringChooserParsonsB.rst +++ b/_sources/MixedFreeResponse/RandomStringChooserParsonsB.rst @@ -55,7 +55,7 @@ Assume that the ``RandomStringChooser`` class that you wrote in part (a) has bee :adaptive: :noindent: - The code below will copy the strings from the array to a list in the constructor using a general for loop. In ``getNext`` it will return "NONE" if the length of the list is 0. Otherwise it till calculate a random index in the list and remove and return the string at that index. The blocks have been mixed up and include extra blocks that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The code below will copy the strings from the array to a list in the constructor using a general for loop. In ``getNext`` it will return "NONE" if the length of the list is 0. Otherwise it till calculate a random index in the list and remove and return the string at that index. The blocks have been mixed up and include extra blocks that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public RandomLetterChooser (String str) { diff --git a/_sources/Unit1-Getting-Started/topic-1-4-assignment.rst b/_sources/Unit1-Getting-Started/topic-1-4-assignment.rst index c3eca7d85..85a81ad0a 100644 --- a/_sources/Unit1-Getting-Started/topic-1-4-assignment.rst +++ b/_sources/Unit1-Getting-Started/topic-1-4-assignment.rst @@ -295,13 +295,13 @@ In the mixed up programs below, drag the blocks to the right to put them in the The following has the correct code that uses a third variable named "temp" to swap the values in h and w. - The code is mixed up and contains one extra block which is not needed + The code is mixed up and contains **one extra block** which is not needed in a correct solution. Drag the needed blocks from the left into the correct order on the right, then check your solution. You will be told if any of the blocks are in the wrong order or if you need to remove one or more blocks. - After three incorrect attempts you will be able to use the Help Me button to make the problem easier. + After three incorrect attempts you will be able to use the *Help Me* button to make the problem easier. ----- int h = 3; int w = 5; diff --git a/_sources/Unit1-Getting-Started/topic-1-9-practice-mixed-code.rst b/_sources/Unit1-Getting-Started/topic-1-9-practice-mixed-code.rst index 76b974286..c48ef1ba9 100644 --- a/_sources/Unit1-Getting-Started/topic-1-9-practice-mixed-code.rst +++ b/_sources/Unit1-Getting-Started/topic-1-9-practice-mixed-code.rst @@ -14,7 +14,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should print Maria's first name on one line and her last name on the next line. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should print Maria's first name on one line and her last name on the next line. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- String firstName = "Maria"; String lastName = "Hernandez"; @@ -32,7 +32,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should print the words to a famous poem. But the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should print the words to a famous poem. But the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- System.out.println("Roses are red"); ===== @@ -49,7 +49,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print Marcus's name on one line and his favorite color on the next line. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print Marcus's name on one line and his favorite color on the next line. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -78,7 +78,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should figure out the cost for each shirt if they are buy 2 and get the third free and they are originally $45 each. But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should figure out the cost for each shirt if they are buy 2 and get the third free and they are originally $45 each. But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- double price = 45; ===== @@ -95,7 +95,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should figure out the cost per person for a dinner including the tip. But the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should figure out the cost per person for a dinner including the tip. But the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- double bill = 89.23; ===== @@ -118,7 +118,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print the number of seconds in 5 days. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print the number of seconds in 5 days. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -149,7 +149,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should calculate the number of months it would take you to save 500 if you make 50 a week. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should calculate the number of months it would take you to save 500 if you make 50 a week. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -179,7 +179,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print the name on one line followed by the age on the next line. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print the name on one line followed by the age on the next line. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -207,7 +207,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print the name on one line and the favorite food on the next line. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print the name on one line and the favorite food on the next line. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -236,7 +236,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should calculate the cost of a trip that is 200 miles when the price of gas is 2.20 and the miles per gallon is 42. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should calculate the cost of a trip that is 200 miles when the price of gas is 2.20 and the miles per gallon is 42. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -267,7 +267,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should calculate how many miles you can go on half a tank of gas if the miles per gallon is 26 and your tank holds 15 gallons. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should calculate how many miles you can go on half a tank of gas if the miles per gallon is 26 and your tank holds 15 gallons. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -297,7 +297,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should calculate how many chicken wings you can buy with $3.50 if the wings are $.60 each. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should calculate how many chicken wings you can buy with $3.50 if the wings are $.60 each. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -326,7 +326,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should calculate how much you will have to pay for an item that is 60% off the original price of $52.99. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should calculate how much you will have to pay for an item that is 60% off the original price of $52.99. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -357,7 +357,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should calculate how much the per item costs is for shorts that are buy 2 and get the third free. The shorts are $39.99 each. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should calculate how much the per item costs is for shorts that are buy 2 and get the third free. The shorts are $39.99 each. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { diff --git a/_sources/Unit10-Inheritance/ooParsonsPractice.rst b/_sources/Unit10-Inheritance/ooParsonsPractice.rst index d40086ec8..becab6ad0 100644 --- a/_sources/Unit10-Inheritance/ooParsonsPractice.rst +++ b/_sources/Unit10-Inheritance/ooParsonsPractice.rst @@ -14,7 +14,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should create an abstract class with an abstract method walk(). But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should create an abstract class with an abstract method walk(). But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public abstract class Dog { ===== @@ -33,7 +33,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should create an empty Dog class that is a child of the Animal class. But, the blocks have been mixed up and may include extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should create an empty Dog class that is a child of the Animal class. But, the blocks have been mixed up and may include extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Dog extends Animal { ===== @@ -51,7 +51,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program should overload a void method talk with no parameters. But, the blocks have been mixed up and may include extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program should overload a void method talk with no parameters. But, the blocks have been mixed up and may include extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class GenericPerson { @@ -83,7 +83,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program should create an interface, named Person, with two methods, walk() and talk(). But, the blocks have been mixed up and may include extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program should create an interface, named Person, with two methods, walk() and talk(). But, the blocks have been mixed up and may include extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public interface Person { ===== diff --git a/_sources/Unit11-Recursion/rParsonsPractice.rst b/_sources/Unit11-Recursion/rParsonsPractice.rst index ec3481612..8a6ed9a1c 100644 --- a/_sources/Unit11-Recursion/rParsonsPractice.rst +++ b/_sources/Unit11-Recursion/rParsonsPractice.rst @@ -13,7 +13,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :noindent: :adaptive: - The following method should reverse the order of the characters in the given string -- so "abcd" should become "dcba". But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should reverse the order of the characters in the given string -- so "abcd" should become "dcba". But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static String reverse(String myText) { @@ -38,7 +38,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following method should multiply the two passed-in positive integers (using the fact that multiplcation is repeated addition) -- so multipy(3, 4) should become 12 (3+3+3+3). But the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should multiply the two passed-in positive integers (using the fact that multiplcation is repeated addition) -- so multipy(3, 4) should become 12 (3+3+3+3). But the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int multiply(int a, int b) { @@ -67,7 +67,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :noindent: :adaptive: - The following method should add up all of the elements in the passed-in array -- so {1,2,3,12} should return 18 (Note when the method is called, the index will always start off as 0). But the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should add up all of the elements in the passed-in array -- so {1,2,3,12} should return 18 (Note when the method is called, the index will always start off as 0). But the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int sumElements(int[] arr, int index) { @@ -98,7 +98,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following method should remove any occurrence of an asterisk "*" from a passed-in string -- so "ab*c**d" should become "abcd". But the blocks have been mixed up. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should remove any occurrence of an asterisk "*" from a passed-in string -- so "ab*c**d" should become "abcd". But the blocks have been mixed up. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static String removeStar(String myText) { @@ -128,7 +128,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :noindent: :adaptive: - The following method should return the base multiplied power times. In otherwords, the base ^ power -- so exponent(2, 4) should return 16. But the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should return the base multiplied power times. In otherwords, the base ^ power -- so exponent(2, 4) should return 16. But the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int exponent(int base, int power) { @@ -156,7 +156,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :noindent: :adaptive: - The following method should return the number of times "5" is an element in the passed-in array -- so {1, 5, 7, 14, 5} will return 2 (Note that when the method is called the index will always start off as 0). But the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should return the number of times "5" is an element in the passed-in array -- so {1, 5, 7, 14, 5} will return 2 (Note that when the method is called the index will always start off as 0). But the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int numFiveOccurrence(int[] arr, int index) { @@ -191,7 +191,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following method should repeat the passed-in string a set number of times -- so repeatThis("hi", 3) should return "hihihi". But the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should repeat the passed-in string a set number of times -- so repeatThis("hi", 3) should return "hihihi". But the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static String repeatThis(String s, int i) { @@ -222,7 +222,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :noindent: :adaptive: - The following method should return number of times the character " x " is in a String -- so findNumX("xHihxixx") should return 4. But the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should return number of times the character " x " is in a String -- so findNumX("xHihxixx") should return 4. But the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int findNumX(String s) { @@ -256,7 +256,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following method should return a string counting from 1 to the specified number -- so countTo(4) should return "1...2...3...4...". But the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should return a string counting from 1 to the specified number -- so countTo(4) should return "1...2...3...4...". But the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static String countTo(int x) { @@ -287,7 +287,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :noindent: :adaptive: - The following method should take an passed-in number and return a string such that only the even numbers are still present. All of the odd digits should be replaced with a "_" -- so 4321 should become "4_2_". But the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following method should take an passed-in number and return a string such that only the even numbers are still present. All of the odd digits should be replaced with a "_" -- so 4321 should become "4_2_". But the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static String displayEvenDigits(int num) { diff --git a/_sources/Unit2-Using-Objects/topic-2-1-objects-intro-turtles.rst b/_sources/Unit2-Using-Objects/topic-2-1-objects-intro-turtles.rst index 3fd92e27a..56cff3f0a 100644 --- a/_sources/Unit2-Using-Objects/topic-2-1-objects-intro-turtles.rst +++ b/_sources/Unit2-Using-Objects/topic-2-1-objects-intro-turtles.rst @@ -19,7 +19,14 @@ :align: middle :alt: groupwork +.. |turtleFLF| image:: ../../_static/turtleForwardLeftForward.png + :width: 150 + :align: top +.. |turtleFRF| image:: ../../_static/turtleTurnForwardRightForward.png + :width: 150 + :align: top + .. |repl| raw:: html @@ -345,18 +352,22 @@ instead of 100. You would do this using the code ``yertle.forward(50);``. :adaptive: :noindent: - The following program uses a turtle to draw a sort-of sideways capital L as shown to the - left, - but the lines are mixed up. The program should do all necessary + + |turtleFLF| + + The following program uses a turtle to draw a sort-of sideways capital L as shown above to the + left, but the lines are mixed up. The program should do all necessary set-up: start the class definition, start the main method, and create a world and turtle. Then it should ask the turtle to turn right, go forward, turn left, and then go forward 50 pixels. Next, it should ask the world to show itself. Finally, it should close the main method and class definition. We have added a compass to the picture to indicate the directions - north, south, west, and east.

Drag the needed blocks of statements from the left column to the right column and put them in the right order. - There are three extra blocks that are not needed in a correct solution. - Then click on Check Me to see if you are right. You will be told if - any of the lines are in the wrong order or are the wrong blocks.

- + north, south, west, and east. + + Drag the needed blocks of statements from the left column to the right column and put them in the right order. + There are **three extra blocks** that are not needed in a correct solution. + Then click on *Check Me* to see if you are right. You will be told if + any of the lines are in the wrong order or are the wrong blocks. + ----- public class TurtleExample3 { ===== @@ -391,7 +402,23 @@ instead of 100. You would do this using the code ``yertle.forward(50);``. :adaptive: :noindent: - The following program uses a turtle to draw the picture shown to the left, but the lines are mixed up. The program should do all necessary set-up: start the class definition, start the main method, and create a world and turtle. Then it should ask the turtle to turn 45 degrees, go forward 100 pixels, turn right, and then go forward 50 pixels. Next, it should ask the world to show itself. Finally, it should close the main method and class definition. We have added a compass to the picture to indicate the directions north, south, west, and east.

Drag the needed blocks of statements from the left column to the right column and put them in the right order. There are three extra blocks that are not needed in a correct solution. Then click on Check Me to see if you are right. You will be told if any of the lines are in the wrong order or are the wrong blocks.

+ |turtleFRF| + + The following program uses a turtle to draw the picture shown above to the left, + but the lines are mixed up. The program should do all necessary set-up: + start the class definition, start the main method, and create a world and turtle. + Then it should ask the turtle to turn 45 degrees, go forward 100 pixels, turn right, + and then go forward 50 pixels. Next, it should ask the world to show itself. + Finally, it should close the main method and class definition. + We have added a compass to the picture to indicate the directions north, south, west, and east. + + + Drag the needed blocks of statements from the left column to the right + column and put them in the right order. There are **three extra blocks** + that are not needed in a correct solution. Then click on *Check Me* to + see if you are right. You will be told if any of the lines are in the + wrong order or are the wrong blocks. + ----- public class TurtleExample4 { ===== diff --git a/_sources/Unit2-Using-Objects/topic-2-11-practice-mixed-code.rst b/_sources/Unit2-Using-Objects/topic-2-11-practice-mixed-code.rst index bdb131ac0..02837c25a 100644 --- a/_sources/Unit2-Using-Objects/topic-2-11-practice-mixed-code.rst +++ b/_sources/Unit2-Using-Objects/topic-2-11-practice-mixed-code.rst @@ -17,7 +17,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print a random number from 1 to 50. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print a random number from 1 to 50. But, the blocks have been mixed up and may include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -45,7 +45,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print the first 2 characters of the message followed by the last 2 characters of the message. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print the first 2 characters of the message followed by the last 2 characters of the message. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -74,7 +74,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print the initials in lowercase letters. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print the initials in lowercase letters. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -109,7 +109,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print the message in all uppercase letters. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print the message in all uppercase letters. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -136,7 +136,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print the first 3 letters of message in uppercase letters. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print the first 3 letters of message in uppercase letters. But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { @@ -165,7 +165,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The main method in the following class should print the part of the message starting with the word "nice". But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The main method in the following class should print the part of the message starting with the word "nice". But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public class Test1 { diff --git a/_sources/Unit2-Using-Objects/topic-2-9-Math.rst b/_sources/Unit2-Using-Objects/topic-2-9-Math.rst index 8a66be680..372c509b7 100644 --- a/_sources/Unit2-Using-Objects/topic-2-9-Math.rst +++ b/_sources/Unit2-Using-Objects/topic-2-9-Math.rst @@ -252,7 +252,8 @@ Now what about the combination lock for this challenge? It has 3 dials with 0-40 :language: java :autograde: unittest - Complete the combination lock challenge below. + Complete the combination lock challenge below. **Note:** Only separate the numbers by whitespace. + Don't use commas or words to describe what the program is doing. ~~~~ public class MathChallenge { diff --git a/_sources/Unit3-If-Statements/magpie-exercises.rst b/_sources/Unit3-If-Statements/magpie-exercises.rst index 27f9e34d7..31924556f 100644 --- a/_sources/Unit3-If-Statements/magpie-exercises.rst +++ b/_sources/Unit3-If-Statements/magpie-exercises.rst @@ -15,7 +15,7 @@ Mixed Up Code Practice :adaptive: :noindent: - The following program segment should print 4 random responses using if/else statements, but the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should print 4 random responses using if/else statements, but the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- private String getRandomResponse() { diff --git a/_sources/Unit3-If-Statements/topic-3-3-if-else.rst b/_sources/Unit3-If-Statements/topic-3-3-if-else.rst index 092b0425d..7d53c2a6a 100644 --- a/_sources/Unit3-If-Statements/topic-3-3-if-else.rst +++ b/_sources/Unit3-If-Statements/topic-3-3-if-else.rst @@ -228,7 +228,7 @@ Notice the second condition is simply the negation of the first condition. :adaptive: :noindent: - The following program should print out "x is even" if the remainder of x divided by 2 is 0 and "x is odd" otherwise, but the code is mixed up. Drag the blocks from the left and place them in the correct order on the right. Click on Check Me to see if you are right. + The following program should print out "x is even" if the remainder of x divided by 2 is 0 and "x is odd" otherwise, but the code is mixed up. Drag the blocks from the left and place them in the correct order on the right. Click on *Check Me* to see if you are right. ----- public class EvenOrOdd { diff --git a/_sources/Unit3-If-Statements/topic-3-9-practice-mixed-code.rst b/_sources/Unit3-If-Statements/topic-3-9-practice-mixed-code.rst index 947df8af8..68490343c 100644 --- a/_sources/Unit3-If-Statements/topic-3-9-practice-mixed-code.rst +++ b/_sources/Unit3-If-Statements/topic-3-9-practice-mixed-code.rst @@ -48,7 +48,7 @@ two that aren't needed in the correct solution. The following program segment should print either "You can go out" if you don't have any homework and have cleaned and - otherwise should print "You can not go out". But the blocks have been mixed up and includes one extra block that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. + otherwise should print "You can not go out". But the blocks have been mixed up and includes **one extra block** that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 { @@ -79,7 +79,7 @@ two that aren't needed in the correct solution. :adaptive: :noindent: - The main method in the following class should print if x is in the range of 1 to 10 (inclusive) or not. But, the blocks have been mixed up and includes an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print if x is in the range of 1 to 10 (inclusive) or not. But, the blocks have been mixed up and includes **an extra block** that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -110,7 +110,7 @@ two that aren't needed in the correct solution. :adaptive: :noindent: - The main method in the following class should print out if a string has the word "ringing" in it or not. But, the blocks have been mixed up and includes an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print out if a string has the word "ringing" in it or not. But, the blocks have been mixed up and includes **an extra block** that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -141,7 +141,7 @@ two that aren't needed in the correct solution. :adaptive: :noindent: - The main method in the following class should print if your favorite food is junk food (pizza or wings) or not. But, the blocks have been mixed up and includes an extra block that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print if your favorite food is junk food (pizza or wings) or not. But, the blocks have been mixed up and includes **an extra block** that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -173,7 +173,7 @@ two that aren't needed in the correct solution. :adaptive: :noindent: - The main method in the following class should print your fine if you are speeding. If you are going over 65 but less than 75 the fine is 50. If you are going at least 75 and less than 85 the fine is 100. Over that the fine is 200. But, the blocks have been mixed up and includes two extra blocks that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print your fine if you are speeding. If you are going over 65 but less than 75 the fine is 50. If you are going at least 75 and less than 85 the fine is 100. Over that the fine is 200. But, the blocks have been mixed up and includes **two extra blocks** that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -237,7 +237,7 @@ two that aren't needed in the correct solution. :adaptive: :noindent: - The main method in the following class should print if you can text now. You can text if you are not driving and not eating. But, the blocks have been mixed up and includes an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print if you can text now. You can text if you are not driving and not eating. But, the blocks have been mixed up and includes **an extra block** that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 diff --git a/_sources/Unit4-Iteration/topic-4-7-practice-mixed-code.rst b/_sources/Unit4-Iteration/topic-4-7-practice-mixed-code.rst index f20c55e6f..20b7d3dd9 100644 --- a/_sources/Unit4-Iteration/topic-4-7-practice-mixed-code.rst +++ b/_sources/Unit4-Iteration/topic-4-7-practice-mixed-code.rst @@ -33,7 +33,7 @@ Try to solve each of the following. Click the *Check* button to check each solut :adaptive: :noindent: - The following program segment should print a countdown from 15 to 0 (15, 14, 13, ... 0). But the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. + The following program segment should print a countdown from 15 to 0 (15, 14, 13, ... 0). But the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -59,7 +59,7 @@ Try to solve each of the following. Click the *Check* button to check each solut :adaptive: :noindent: - The main method in the following class should print up from 0 to 50 by 5 (0, 5, 10, 15 ... 50). But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print up from 0 to 50 by 5 (0, 5, 10, 15 ... 50). But, the blocks have been mixed up and include **an extra block** that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -90,7 +90,7 @@ Try to solve each of the following. Click the *Check* button to check each solut :adaptive: :noindent: - The main method in the following class should print out the values from 0 to 100 by 20's (0, 20, 40, .. 100). But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print out the values from 0 to 100 by 20's (0, 20, 40, .. 100). But, the blocks have been mixed up and include **an extra block** that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -116,7 +116,7 @@ Try to solve each of the following. Click the *Check* button to check each solut :adaptive: :noindent: - The main method in the following class should print out the values from 100 to 0 by 10's (100, 90, 80, ... 0). But, the blocks have been mixed up and include an extra block that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print out the values from 100 to 0 by 10's (100, 90, 80, ... 0). But, the blocks have been mixed up and include **an extra block** that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -144,7 +144,7 @@ Try to solve each of the following. Click the *Check* button to check each solut :adaptive: :noindent: - The main method in the following class should print 3 rows with 6 * in each row. But, the blocks have been mixed up and include two extra blocks that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print 3 rows with 6 ``*`` in each row. But, the blocks have been mixed up and include **two extra blocks** that aren't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -178,7 +178,7 @@ Try to solve each of the following. Click the *Check* button to check each solut :adaptive: :noindent: - The main method in the following class should print 1 (followed by a newline), then 22 (followed by a newline), and then 333 (followed by a newline). But, the blocks have been mixed up and include an extra block that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print 1 (followed by a newline), then 22 (followed by a newline), and then 333 (followed by a newline). But, the blocks have been mixed up and include **an extra block** that isn't needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -208,7 +208,7 @@ Try to solve each of the following. Click the *Check* button to check each solut :adaptive: :noindent: - The main method in the following class should print 11111, 22222, 33333, 44444, and 55555. But, the blocks have been mixed up and contain two extra blocks that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. + The main method in the following class should print 11111, 22222, 33333, 44444, and 55555. But, the blocks have been mixed up and contain **two extra blocks** that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. ----- public class Test1 @@ -243,7 +243,7 @@ Try to solve each of the following. Click the *Check* button to check each solut :adaptive: :noindent: - The main method in the following class should print 11111, 2222, 333, 44, 5. But, the blocks have been mixed up and include one extra block that isn't needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. + The main method in the following class should print 11111, 2222, 333, 44, 5. But, the blocks have been mixed up and include **one extra block** that isn't needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. ----- public class Test1 diff --git a/_sources/Unit7-Arrays/ArrayParsonsPractice.rst b/_sources/Unit7-Arrays/ArrayParsonsPractice.rst index 03ca62bbe..3206dca7d 100644 --- a/_sources/Unit7-Arrays/ArrayParsonsPractice.rst +++ b/_sources/Unit7-Arrays/ArrayParsonsPractice.rst @@ -13,7 +13,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should double each element in the array then print out the new value -- so (1,2,3,4,5) should become (2,4,6,8,10). But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should double each element in the array then print out the new value -- so (1,2,3,4,5) should become (2,4,6,8,10). But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- int[] arr = {1, 2, 3, 4, 5}; ===== @@ -32,7 +32,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should fill an array with elements that count up from 0 to 50 by 5 (0, 5, 10, 15, 20...). But the blocks have been mixed up. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should fill an array with elements that count up from 0 to 50 by 5 (0, 5, 10, 15, 20...). But the blocks have been mixed up. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- int[] arr = new int[11]; ===== @@ -51,7 +51,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should print each element in the array that is even using an enhanced for each loop. But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should print each element in the array that is even using an enhanced for each loop. But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- int[] arr = {14, -5, 2, 17, 29, -8, 36}; ===== @@ -71,7 +71,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should return the smallest integer given an array of integers (the parameter). But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order with the correct indentation on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should return the smallest integer given an array of integers (the parameter). But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order with the correct indentation on the right. Click the *Check Me* button to check your solution. ----- public static int findSmallest(int[] arr) { ===== @@ -99,7 +99,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should return the average given an array of integers (the parameter). But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order with the correct indentation on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should return the average given an array of integers (the parameter). But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order with the correct indentation on the right. Click the *Check Me* button to check your solution. ----- public static double findAverage(int[] arr) { ===== @@ -123,7 +123,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should return the largest integer given an array of integers (the parameter). But, the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the Check Me button to check your solution.

+ The following program segment is a method that should return the largest integer given an array of integers (the parameter). But, the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the *Check Me* button to check your solution. ----- public static int findLargest(int[] arr) { ===== @@ -153,7 +153,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should return an integer array that is "right shifted" by one -- so {6, 2, 5, 3} returns {3, 6, 2, 5} (the parameter). Note that the method return type is int[] which means it will return an int array. But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should return an integer array that is "right shifted" by one -- so {6, 2, 5, 3} returns {3, 6, 2, 5} (the parameter). Note that the method return type is int[] which means it will return an int array. But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int[] shiftRight(int[] arr) { ===== @@ -179,7 +179,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should return a new array of length 2 containing the middle two elements of a given array of integers of even length (the parameter) -- so {1,2,3,4} should return {2,3}. But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should return a new array of length 2 containing the middle two elements of a given array of integers of even length (the parameter) -- so {1,2,3,4} should return {2,3}. But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int[] makeMiddle(int[] arr) { ===== @@ -202,7 +202,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should return string array that is in reverse order -- so {"b", "a", "z"} should return {"z", "a", "b"}. But, the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should return string array that is in reverse order -- so {"b", "a", "z"} should return {"z", "a", "b"}. But, the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static String[] reverse(String[] arr) { ===== @@ -232,7 +232,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program copies the first half of an array given as an argument to the method into a result array which is returned. But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program copies the first half of an array given as an argument to the method into a result array which is returned. But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int[] firstHalf(int[] arr) { ===== diff --git a/_sources/Unit7-Arrays/soundA.rst b/_sources/Unit7-Arrays/soundA.rst index 8e7dcfd45..ce8078eee 100644 --- a/_sources/Unit7-Arrays/soundA.rst +++ b/_sources/Unit7-Arrays/soundA.rst @@ -113,7 +113,7 @@ Mixed Up Code :numbered: left :adaptive: - The method limitAmplitude below contains the correct code for a solution to this problem, but the code blocks are mixed up. Drag the blocks from the left to the right and put them in order with the correct indentation so that the code would work correctly. + The method ``limitAmplitude`` below contains the correct code for a solution to this problem, but the code blocks are mixed up. Drag the blocks from the left to the right and put them in order with the correct indentation so that the code would work correctly. ----- public int limitAmplitude(int limit) { diff --git a/_sources/Unit7-Arrays/soundB.rst b/_sources/Unit7-Arrays/soundB.rst index 6ea028d16..6de5c61ed 100644 --- a/_sources/Unit7-Arrays/soundB.rst +++ b/_sources/Unit7-Arrays/soundB.rst @@ -98,7 +98,7 @@ Mixed Up Code :numbered: left :adaptive: - The method trimSilenceFromBeginning below contains correct code for one solution to this problem, but it is mixed up. Drag the code blocks from the left to the right and put them in order with the correct indention so that the code would work correctly. + The method ``trimSilenceFromBeginning`` below contains correct code for one solution to this problem, but it is mixed up. Drag the code blocks from the left to the right and put them in order with the correct indention so that the code would work correctly. ----- public void trimSilenceFromBeginning() { diff --git a/_sources/Unit7-Arrays/topic-7-3-arrays-with-foreach.rst b/_sources/Unit7-Arrays/topic-7-3-arrays-with-foreach.rst index 690da4a80..2c8894ff0 100644 --- a/_sources/Unit7-Arrays/topic-7-3-arrays-with-foreach.rst +++ b/_sources/Unit7-Arrays/topic-7-3-arrays-with-foreach.rst @@ -395,7 +395,7 @@ Here is an object-oriented example that has the array as a private instance vari :practice: T :adaptive: - The following method has the correct code to return the largest value in an integer array called vals (an instance variable of the current object), but the code is mixed up. Drag the blocks from the left into the correct order on the right and indent them correctly as well. You will be told if any of the blocks are in the wrong order or not indented correctly.

+ The following method has the correct code to return the largest value in an integer array called *vals* (an instance variable of the current object), but the code is mixed up. Drag the blocks from the left into the correct order on the right and indent them correctly as well. You will be told if any of the blocks are in the wrong order or not indented correctly.

----- public int getLargest() { diff --git a/_sources/Unit8-ArrayList/2016freeresponseQ4A.rst b/_sources/Unit8-ArrayList/2016freeresponseQ4A.rst index 4e0e0d20c..9d1aadccb 100644 --- a/_sources/Unit8-ArrayList/2016freeresponseQ4A.rst +++ b/_sources/Unit8-ArrayList/2016freeresponseQ4A.rst @@ -65,7 +65,7 @@ Put the Code in Order :numbered: left :adaptive: - The following has the correct code to solve this problem, but also contains extra code that isn't needed in a correct solution. Drag the needed blocks from the left into the correct order on the right and indent them as well. Check your solution by clicking on the Check Me button. You will be told if any of the blocks are in the wrong or are in the wrong order. You will also be told if the indention is wrong. + The following has the correct code to solve this problem, but also contains extra code that isn't needed in a correct solution. Drag the needed blocks from the left into the correct order on the right and indent them as well. Check your solution by clicking on the *Check Me* button. You will be told if any of the blocks are in the wrong or are in the wrong order. You will also be told if the indention is wrong. ----- public static int totalLetters(List wordList) { diff --git a/_sources/Unit8-ArrayList/2016freeresponseQ4B.rst b/_sources/Unit8-ArrayList/2016freeresponseQ4B.rst index 2186c1595..be749ab67 100644 --- a/_sources/Unit8-ArrayList/2016freeresponseQ4B.rst +++ b/_sources/Unit8-ArrayList/2016freeresponseQ4B.rst @@ -69,7 +69,7 @@ Put the Code in Order :numbered: left :adaptive: - The following has the correct code to solve this problem, but also contains extra code that isn't needed in a correct solution. Drag the needed blocks from the left into the correct order on the right and indent them as well. Check your solution by clicking on the Check Me button. You will be told if any of the blocks are in the wrong or are in the wrong order. You will also be told if the indention is wrong. + The following has the correct code to solve this problem, but also contains extra code that isn't needed in a correct solution. Drag the needed blocks from the left into the correct order on the right and indent them as well. Check your solution by clicking on the *Check Me* button. You will be told if any of the blocks are in the wrong or are in the wrong order. You will also be told if the indention is wrong. ----- public static int basicGapWidth(List wordList, int formattedLen) diff --git a/_sources/Unit8-ArrayList/ListParsonsPractice.rst b/_sources/Unit8-ArrayList/ListParsonsPractice.rst index d00fd405a..1352517ab 100644 --- a/_sources/Unit8-ArrayList/ListParsonsPractice.rst +++ b/_sources/Unit8-ArrayList/ListParsonsPractice.rst @@ -13,7 +13,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should be a class that adds some Strings of conversational phrases to a List and then prints them out. But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the Check Me button to check your solution.

+ The following program segment should be a class that adds some Strings of conversational phrases to a List and then prints them out. But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the *Check Me* button to check your solution. ----- import java.util.List; import java.util.ArrayList; @@ -47,7 +47,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should be a method that traverses through an ArrayList of Strings (the parameter) and print out the elements in reverse order -- so {"cat", "dog", "mouse"} should print "mouse, dog, cat, " as output. Assume the ArrayList "myList" has been instantiated and filled with Strings. But, the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should be a method that traverses through an ArrayList of Strings (the parameter) and print out the elements in reverse order -- so {"cat", "dog", "mouse"} should print "mouse, dog, cat, " as output. Assume the ArrayList "myList" has been instantiated and filled with Strings. But, the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static void printBackwards(ArrayList myList) { ===== @@ -69,7 +69,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should remove all the zeros from an ArrayList of Integers. Assume the ArrayList "listOfNums" has been instantiated and filled with Integers. But, the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should remove all the zeros from an ArrayList of Integers. Assume the ArrayList "listOfNums" has been instantiated and filled with Integers. But, the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- Integer zero = new Integer(0); int i = 0; @@ -99,7 +99,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment is a method that should return the smallest int given an ArrayList of Integers (the parameter). But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should return the smallest int given an ArrayList of Integers (the parameter). But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int findSmallest(ArrayList nums) { ===== @@ -127,7 +127,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment is a method that should remove all the positive and negative odd values in an ArrayList of Integers (the parameter). But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should remove all the positive and negative odd values in an ArrayList of Integers (the parameter). But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static void removeOdd(ArrayList nums) { ===== @@ -155,7 +155,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following method should calculate the average from an ArrayList of Integers (the parameter). But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the Check Me button to check your solution.

+ The following method should calculate the average from an ArrayList of Integers (the parameter). But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the *Check Me* button to check your solution. ----- public static double average(ArrayList nums) { ===== @@ -179,7 +179,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should find the largest value given an ArrayList of Integers (the parameter) and move it to the back of the list. But, the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should find the largest value given an ArrayList of Integers (the parameter) and move it to the back of the list. But, the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static void moveLargest(ArrayList nums) { ===== @@ -210,7 +210,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following method should remove all the Strings that have length 3 or shorter from an ArrayList of Strings (the parameter) -- so {"catch", "dog", "tree", "me"} should return {"catch", "tree"}. But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the Check Me button to check your solution.

+ The following method should remove all the Strings that have length 3 or shorter from an ArrayList of Strings (the parameter) -- so {"catch", "dog", "tree", "me"} should return {"catch", "tree"}. But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the *Check Me* button to check your solution. ----- public static void removeShort(ArrayList words) { ===== @@ -238,7 +238,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should take each String from an ArrayList of Strings (the parameter) and add it again to the list -- so {"cat", "ribbon", "house"} should become {"cat", "cat", "ribbon", "ribbon", "house", "house"}. But, the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should take each String from an ArrayList of Strings (the parameter) and add it again to the list -- so {"cat", "ribbon", "house"} should become {"cat", "cat", "ribbon", "ribbon", "house", "house"}. But, the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static void doubleList(ArrayList words) { ===== @@ -265,7 +265,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following method should remove a specific Integer (specified in parameter) whenever it occurs in a given ArrayList of Integers (the parameter). But, the blocks have been mixed up and include three extra blocks that are not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the Check Me button to check your solution.

+ The following method should remove a specific Integer (specified in parameter) whenever it occurs in a given ArrayList of Integers (the parameter). But, the blocks have been mixed up and include **three extra blocks** that are not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the *Check Me* button to check your solution. ----- public static void removeElement(ArrayList nums, int toRemove) { diff --git a/_sources/Unit9-2DArray/Array2dParsonsPractice.rst b/_sources/Unit9-2DArray/Array2dParsonsPractice.rst index 4a92458fb..17f1f7f5f 100644 --- a/_sources/Unit9-2DArray/Array2dParsonsPractice.rst +++ b/_sources/Unit9-2DArray/Array2dParsonsPractice.rst @@ -14,7 +14,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should create a 10 by 10 two-dimensional int array. It should fill this array with numbers 0 to 99 from left to right, top row to bottom row and print the output (in row-column order). But, the blocks have been mixed up and contain an extra block that is not needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should create a 10 by 10 two-dimensional int array. It should fill this array with numbers 0 to 99 from left to right, top row to bottom row and print the output (in row-column order). But, the blocks have been mixed up and contain an extra block that is not needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- int[][] table = new int[10][10]; ===== @@ -37,7 +37,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment should create a 8 by 8 two-dimensional int array. It should fill this array with a checkered pattern of 0s and 1s -- starting with a 1 in the top left corner and print the output (in row-column order). But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment should create a 8 by 8 two-dimensional int array. It should fill this array with a checkered pattern of 0s and 1s -- starting with a 1 in the top left corner and print the output (in row-column order). But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- int[][] checkerboard = new int[8][8]; ===== @@ -64,7 +64,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment is a method that should accept a two-dimensional int array and return the sum of all of its values. But, the blocks have been mixed up and include three extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should accept a two-dimensional int array and return the sum of all of its values. But, the blocks have been mixed up and include **three extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int sumVals(int[][] nums) { ===== @@ -103,7 +103,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so 1 2 3 4  ->  4 3 2 1
1 2 3 4        4 3 2 1
- But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static void flipImage(String[][] image) { ===== @@ -129,7 +129,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :adaptive: :noindent: - The following program segment is a method that should accept a two-dimensional array of ints and edit it such that all even numbers are replaced by zero. But, the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should accept a two-dimensional array of ints and edit it such that all even numbers are replaced by zero. But, the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static void makeEvenNumsZero(int[][] nums) { ===== @@ -158,7 +158,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should accept a two-dimensional array of ints and a desired int and return the number of occurrences of the desired int in the two-dimensional array. But, the blocks have been mixed up and include two extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should accept a two-dimensional array of ints and a desired int and return the number of occurrences of the desired int in the two-dimensional array. But, the blocks have been mixed up and include **two extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int numOccurrences(int[][] nums, int desired) { @@ -190,7 +190,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should accept a two-dimensional int array and return a single dimensional (normal) int array containing the average of each of the columns. But, the blocks have been mixed up and include three extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should accept a two-dimensional int array and return a single dimensional (normal) int array containing the average of each of the columns. But, the blocks have been mixed up and include **three extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int[] averageCols(int[][] nums) { ===== @@ -224,7 +224,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should accept a two-dimensional int array and return a new two-dimensional int array containing only the odd index rows. But, the blocks have been mixed up and include three extra blocks that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check Me button to check your solution.

+ The following program segment is a method that should accept a two-dimensional int array and return a new two-dimensional int array containing only the odd index rows. But, the blocks have been mixed up and include **three extra blocks** that are not needed in a correct solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the *Check Me* button to check your solution. ----- public static int[][] oddRows(int[][] nums) { ===== @@ -270,7 +270,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so Resulting array: {"bath", "tens", "jack", "lazy"} - But, the blocks have been mixed up. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the Check Me button to check your solution.

+ But, the blocks have been mixed up. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the *Check Me* button to check your solution. ----- public static String[] breakIntoLetters(String[][] words) { ===== @@ -297,7 +297,7 @@ Try to solve each of the following. Click the *Check Me* button to check each so :practice: T :adaptive: - The following program segment is a method that should accept a two-dimensional int array, and return a single-dimensional (normal) int array containing the max of each row. But, the blocks have been mixed up and include one extra block that is not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the Check Me button to check your solution.

+ The following program segment is a method that should accept a two-dimensional int array, and return a single-dimensional (normal) int array containing the max of each row. But, the blocks have been mixed up and include **one extra block** that is not needed in a correct solution. Drag the needed code from the left to the right and put them in order with the correct indention so that the code would work correctly. Click the *Check Me* button to check your solution. ----- public static int[] maxEachRow(int[][] nums) { ===== diff --git a/_sources/Unit9-2DArray/topic-9-2-2D-array-loops-Day1.rst b/_sources/Unit9-2DArray/topic-9-2-2D-array-loops-Day1.rst index c7da82ad7..76caa47c1 100644 --- a/_sources/Unit9-2DArray/topic-9-2-2D-array-loops-Day1.rst +++ b/_sources/Unit9-2DArray/topic-9-2-2D-array-loops-Day1.rst @@ -176,7 +176,7 @@ Some key things to notice about this code are: :practice: T :adaptive: - The following has the correct code to find the largest value in a 2D array. Drag the blocks from the left into the correct order on the right and indent them as well. Check your solution by clicking on the Check Me button. You will be told if any of the blocks are in the wrong order or have the wrong indention. + The following has the correct code to find the largest value in a 2D array. Drag the blocks from the left into the correct order on the right and indent them as well. Check your solution by clicking on the *Check Me* button. You will be told if any of the blocks are in the wrong order or have the wrong indention. ----- public static int getLargest(int[][] arr) { =====