Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

== public static void isValidMove(String from, String to) { 1. if ((from null || from.trim().isEmpty()) || (to == null || to.tr im().isEmpty()) { // A

image text in transcribed

image text in transcribed

== public static void isValidMove(String from, String to) { 1. if ((from null || from.trim().isEmpty()) || (to == null || to.tr im().isEmpty()) { // A 2. return "Invalid: and both needs to be non-empty str ings" ; 3. } 4. 5. if (from.equals("stock") && isValidPileNumber(to)) { // B 6. return "Valid: stock to pile" 7. } else if (from.equals("stock") && SUITS.contains(to)) { // C 8. return "Valid: stock to suit" 9. } else if (isValidPileNumber(from)) { // D 10. if (!(isValidPileNumber(to) || SUITS.contains(to))) { // E 11. return "Invalid: value is invalid"; 12. } 13. return "Valid: pile to (pile or suit)" 14. } 15. return "Invalid or value"; } // Helper variables and methods public static final Collection SUITS = Arrays.asList("s", "d", "h ", "C"); > public static boolean isValidPileNumber (String input) { try { int i = Integer.parseInt(input.trim()); return i >= 1 && i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

3. How do todays organizations diff er from those of earlier eras?

Answered: 1 week ago