33import  com .booleanuk .helpers .ExtensionBase ;
44
55public  class  Extension  extends  ExtensionBase  {
6+ 
7+     public  float  add (float  float1 , float  float2 ) {
8+         return  float1  + float2 ;
9+     }
10+ 
11+     public  double  add (double  d1 , double  d2 ) {
12+         return  d1  + d2 ;
13+     }
14+ 
15+     public  float  subtract (float  f1 , float  f2 ) {
16+         return  f1 -f2 ;
17+     }
18+ 
19+     public  String  subtract (String  str , char  c ) {
20+         String  res  = "" ;
21+         for  (int  i  = 0 ; i  < str .length (); i  ++) {
22+             if  (str .charAt (i ) != c ) {
23+                 res  += str .charAt (i );
24+             }
25+         }
26+         return  res ;
27+     }
628    /* 
729        Implement the following methods: 
830
@@ -20,11 +42,35 @@ public class Extension extends ExtensionBase {
2042        as many times as the provided int separated by a comma. E.g. 
2143        multiply("Hello", 3) -> "Hello,Hello,Hello" 
2244
23-         7. multiply, which accepts an array of Strings that each contain a number, and an int 
45+ 
46+      */ 
47+     public  int  multiply (int  i1 , int  i2 ) {
48+         return  i1  * i2 ;
49+     }
50+ 
51+     public  String  multiply (String  str , int  i ) {
52+         String  res  = str  + "," ;
53+         while  (i  > 2 ) {
54+             res  += str  + "," ;
55+             i  --;
56+         }
57+         res  += str ;
58+         return  res ;
59+     }
60+ 
61+     /* 
62+     7. multiply, which accepts an array of Strings that each contain a number, and an int 
2463        The method should return an array of ints that contain the value of multiplying each String number by the provided int 
2564        E.g. 
2665        multiply(["2", "7", "3"], 3) -> [6, 21, 9] 
2766     */ 
67+     public  int [] multiply (String [] iString , int  factor ) {
68+         int [] res  = new  int [iString .length ];
69+         for  (int  i  = 0 ; i  < iString .length ; i  ++) {
70+             res [i ] = Integer .parseInt (iString [i ]) * factor ;
71+         }
72+         return  res ;
73+     }
2874
2975
3076}
0 commit comments