CS 200 Projects
Overview
In CS 200 I learned how to use Java and was introduced further to coding. I learned key topics like methods, loops, arrays, array lists, objects and files. I implemented thes topics throughout the course in various assignments, labs and specifically in the final project.
Final Project
The final project for this class required us to create an "adventure" game in which the player is tasked with finding something on a map by moving around to different spaces until the either win or loose.
- If-Else
-
I used if-else statements along with try catch blocks in the code numerous times. One instance was in a test method that checked whether the code to parse certain fields was working correctly.
private static void testParseFields() { boolean error = false; { String fieldString = "size/This is the size of the map//"; String[] expected = new String[]{"size","This is the size of the map","",""}; String [] actual = Adventure.parseFields(fieldString); if (!Arrays.equals(expected, actual)) { System.out.println("testParseFields 1) Expected: " + Arrays.toString( expected) + " Actual: " + Arrays.toString( actual)); error = true; } } if ( error) { System.out.println("Error in testParseFields."); } else { System.out.println("All tests in testParseFields passed."); } }
- Loops
-
In the code I used various loops to iterate through arrays. One instance was a for loop I used to iterate through an array to trim each coordinate at each point.
String[] array = fieldInformation.split("/",-1); for(int i = 0; i< array.length; i++) { array[i] = array[i].trim(); } return array;
- © Untitled
- Design: HTML5 UP