/ Published in: Java
Doublets Project
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.util.Scanner; public class Main { // dictionary Doublets doublets; // Initialize the doublets // Variable input so user selects dictionary. System.out .println("Enter a dictionary number (10, 20, 35, 40, 50, 55, 60, 70, 80, 95): "); doublets = new Doublets(new Links(filename)); // Continue game until user specifies to quit with an 'x' key stroke. while (true) { start = start.trim(); end = end.trim(); // Check to make sure words are valid. if (!doublets.isInDictionary(start)) { } else if (!doublets.isInDictionary(end)) { } else if (start.length() != end.length()) { System.out .println("The words need to be the same length. Try again!"); } else if (start.equals(end)) { } else { // Select the chain manager ChainManager manager; while (true) { System.out .println("Enter chain manager (s: stack, q: queue, p: priority queue, x: exit): "); if (m.equals("s")) { manager = new StackChainManager(); break; } else if (m.equals("q")) { manager = new QueueChainManager(); break; } else if (m.equals("p")) { manager = new PriorityQueueChainManager(end); break; } else if (m.equals("x")) { input.close(); } else { } } // Find the chain Chain chain = doublets.getChain(start, end, manager); // If there is no solution if (chain == null) else { + manager.getNumberOfNexts()); } } } } }