Question: What would be the main method for this? When i submitted this the professor said i'm missing the main method class InputChecker{ boolean isLetterString(String rope){
What would be the main method for this? When i submitted this the professor said i'm missing the main method
class InputChecker{ boolean isLetterString(String rope){ //ROPE it's like string, but manlier try{ char[] intern = rope.toCharArray(); if(rope.length() == 0) return false; for(int i = 0; i < rope.length(); i++){ if((intern[i] > 90 && intern[i] < 97) || (intern[i] < 65) || (intern[i] > 122)) return false; } return true; } catch (NullPointerException e){ return false; } }
boolean hasValidFormat(String rope){ try{ int index = rope.indexOf('.'); if(index == -1) return false; String OldKanye = rope.substring(0, index); String NewKanye = rope.substring(index + 1); if(OldKanye.length() == 0 || NewKanye.length() != 3) return false; return isLetterString(OldKanye) && isLetterString(NewKanye); } catch (NullPointerException e){ return false; } }
boolean isShortString(String rope) throws Exception { int OSRS; try{ OSRS = rope.length(); } catch (NullPointerException e){ return false; } if(OSRS <= 16) return true; else throw new Exception("You have more than 16 letters"); } public class InputCheckerTest { public void main(String[] args) { String first = "helloWorld"; String second = "test.com"; String third = "ThisIsMoreThanSixteen"; try { InputChecker checker = new InputChecker(); System.out.println(checker.isLetterString(first)); System.out.println(checker.isLetterString(second));
System.out.println(checker.hasValidFormat(second)); System.out.println(checker.hasValidFormat(first));
System.out.println(checker.isShortString(third)); } catch (Exception e){ System.out.println("Exception: " + e.getMessage()); } }}}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
