Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java - CCDemo Palindrome

dantheman
dantheman 


Collection Classes Create a class called CCDemo. It should belong to package cs1410 and should contain completed implementations of the following methods. Include a main method that tests the other methods. /** * Returns the set containing every string from allStrings that * is a palindrome. For example, if allStrings is [aba, a, bc], * the method should return [aba, a]. */ public static Set palindromes (Set allStrings) { return null; } /** * The return value maps each string s in allStrings to the number of * other strings from allStrings of which s is a substring. For example, * if allStrings is [xyz, x, y, yz], the method should return * {x=1, y=2, yz=1}. */ public static Map substringCount (Set allStrings) { return null; } /** * Returns a list containing the strings from allStrings, arranged in * order of increasing length. The relative ordering of two equal-length * strings does not matter. For example, if allStrings is [xyz, ab, a, xy], * the method should return [a, ab, xy, xyz] or [a, xy, ab, xyz]. */ public static List sortByLength (Set allStrings) { return null; } Hint: In sortByLength, you should use the two-parameter Collections.sort method. You will need to make a helper class that implements the Comparator interface, and then pass in an object of this class as the second parameter to Collections.sort. You can put this class into CCDemo.java so long as you don't declare it public. LightsOut In this problem, you will get experience with graphical user interfaces by building a "Lights Out" puzzle in Java. Visit this link to familiarize yourself with Lights Out. Notice that the playing board is a 5x5 grid of lights. A light is either on or off. When you click on a light, the on/off state of that light---as well as the lights above, below, to the left, and to the right of it---toggle. The goal of the puzzle is to turn all of the lights off. Your GUI should: 1. Be attractive. 2. Have a 5x5 game grid of buttons. You can use square instead of round buttons if you'd like. 3. Have a "Randomize" button that randomly sets the state of each grid button. (Use a java.util.Random object to generate random numbers.) 4.Report when the player has won the game (turned all the lights off) by displaying a dialog box. 5.Have an "Enter Manual Setup" button. The text of the button should change to "Exit Manual Setup" and the game should enter manual setup mode. In this mode, clicking on a grid button should toggle only the grid button being clicked, not any of its neighbors. When the "Exit Manual Set" button is clicked, normal game play should resume. The purpose of manual setup mode is to allow a player to configure a game any way he or she pleases. 6. Close the window and shut down when the window's X icon is clicked. Your program should consist of the single file LightsOut.java. It should contain a public class called LightsOut whose main method launches the application. If you need another class, put it in the same file but don't declare it public. Turning In Use the control below to submit CCDemo.java and LightsOut.java. Attachments
Tags Clarifications

Answers

CCDemo Only - Java

dickersonka
dickersonka 



Attached is the CCDemo java solution Attachments
CCDemo.zip (22 K) Download
Preview
setString += ", "; } index++; } setString += "]"; return setString; } private static String listToString(List<String> list){ int index = 0; String setString = "["; for(String p : list){ setString += p; if(index <

Preview

Screenshots
Screenshot
Purchase Answer