Answered You can buy a ready-made answer or pick a professional tutor to order an original one.
Instructions This assignment will help students understand interface implementation as a crucial software engineering component. You will implement the given interface in JAVA. Overall interface co
Instructions This assignment will help students understand interface implementation as a crucial software engineering component. You will implement the given interface in JAVA. Overall interface coding This assignment requires you to write the Utilities211Code.java class which implements the Utilities211Interface.java interface shown below. After you have written the code for the Utilities211Code.java program, you will then test your code with the Utilities211Driver.java code that I provide for you at the end of the page. The expected results are at the bottom of the page as well. Each of the methods properly implemented Overall coding practices, comments, following the ICS Java coding standard, correct results printed. Utilfties211Interface: abstract interface Utilities 211 Interface /* Method reads a string and verifies that the string contains at least 2 non-blank characters. For example if the String is " a b " the string length is 7 and the method returns true " x " the string length is 8 and the method returns false "" the string length is 0 and the method returns false " " the string length is 12 and the method returns false "123abc" the string length is 6 and the method returns true Just pointing out that the length of the string doesn't determine the validity of the string. @param String s the string to be tested @return boolean valid = true, false otherwise */ abstract boolean validString(String s); /* @param double d number to be tested @returnint 1 of the number is positive −1 of the number is negative 0 of the number is zero */ abstract int numberSign(double d); /* This method receives 2 int numbers and counts the numbers in range between them For example if int 1=20 and int 2=33 it will return 13 if int 1=12 and int 2=−5 it will return 17 @param int1, int2, numbers defining the range @return int, range */ abstract int range(int i1, int i2); \} Utilities211Driver.java. Use it to test your code. public class Utilities211Driver\{ public static void main(String[ ] arg)র double d=−2.1 int x=5; int y=−6; String s1= " x "; String s2= " cow "; Utilities211Code u = new Utilities211Code( ); System.out.printIn(u.validString(s1)); System.out.println(u.validString(s2)); System.out.println(u.numberSign( d )); System.out.println(u.range( (x,y) ); \} \} Your output when running this program should be:
Please provide assistance in writing a Code that will implement Utilities211Interface and Utilities211Driver. Thank you
- @
- ANSWER
Java code
public abstract interface Utilities211Interface { abstract boolean validString(String s); abstract int numberSign(double d); abstract int range(int i1, int i2); }
import java.util.*; public class Utilities211Code implements Utilities211Interface { public boolean validString(String s){ s =s.replaceAll("\\s", ""); if(s.length() >=2 ) return true; else return false; } public int numberSign(double d){ if(d >0) return 1; else if(d <0) return -1; else return 0; } public int range(int i1, int i2){ int count =0; if(i1 > i2 ){ for(int i = i2 ; i <i1 ; i++ ){ count++; } return count; } else{ for(int i = i1 ; i <i2 ; i++ ){ count++; } return count; } } }
public class Utilities211Driver { public static void main(String[] args){ double d= −2.1 ; int x = 5; int y = −6; String s1 = "x "; String s2 = "cow "; Utilities211Code u = new Utilities211Code( ); System.out.println(u.validString(s1)); System.out.println(u.validString(s2)); System.out.println(u.numberSign( d )); System.out.println(u.range( x,y ) ); } }