There are three pages First one is the interface Second page

There are three pages. First one is the interface. Second page you have A (1-6) and B (1-6) and C

RIP OUT TO USE ON PROBLEM 6: 6. [15] Use the following BoundedStringset and partial implementation BoundedStringsetlmpl for this problem: public interface BoundedString Set public int capacity Ex: \"bz\", \"ftg\", \"kdjfas\" 1.sizeC) returns 3 Ex: 1\"22\", twenty\" sized returns 2 //EX: size() returns 0 public int size //Ex: (\"bz\", \"ftg\", \"kdjfas\" .addC\"abc\") changes the set to bz\", ftg\", \"kdjfas\", \"abc\" //EX: (\"a\", \"c\", \"b\") add null) results in a precondition //violation //EX: \"a\", \"c\", \"b\" .addC\"b\") changes the set to 1\"a\", \"c\", \"b\" public void add(String s); //EX: a\", \"b\", \"c\"1.removec\"b\") changes the set to f\" a\", \"c\" //EX: a\", \"b\", c removed\"d\") changes the set to t\"a\", \"b\", \"c\"h public void remove CString s); //EX: a\", \"c\", \"b\" .contains a\") returns true //EX: 1\"a\", \"c\", \"b\"}.containsC\"b\") returns true //EX: {\"a\", \"c\", \"b\" .contains C\"zz\") returns false public boolean contains String s public class Bounded Stringsetimpl implements Bounded String Set private String[] stringArray; public Boundedstringsetimpl int capacity) stringArray new String[capacity] public void remove String s int index OfMatch get Index0fMatchCs); if(index 0fMatch 1) str null

Solution


a)
   a1 = {\"s\", \"t\", \"u\", \"u\"}

       NOT WELL-FORMED (duplicate value)

   a2 . [\"s1\", null, null, \"s2\"]
       size = 2
       capacity = 4

   a3. []
       size = 0
       capacity = 0

   a4. [\"a\", null, \"b\", null, null, \"c\"]
       size = 6
       capacity = 6

   a5. [] size = 0, capacity = 0

   a6. [null, null, null, null]
       size = 0;
       capacity = 4

b)
   c1. {\"c\", \"b\", \"a\"} : 4
       array = [\"c\", \"b\", \"a\", null]

   c2. {\"d\", \"e\", \"f\", \"g\"}:1
       NONE, capacity should be at least 4

   c3. {} : 3
       array : [null, null, null]

   c4. {\"a\",\"b\", \"c\"}:6
       array = [\"a, \"b, \"c\", null, null, null]

   c5. {\"d\", \"k\"}:2
       array : [\"d\", \"k\"]

   c6. {\"a\", null, \"b\"}:3
       NONE

c)
   public int size(){

       int coutn = 0;
       for(int i=0; i<stringArray.lenght; i++){
           if(stringArray[i] != null)
               coutn = coutn + 1;
       }

       return count;
   }

There are three pages. First one is the interface. Second page you have A (1-6) and B (1-6) and C RIP OUT TO USE ON PROBLEM 6: 6. [15] Use the following Bounded
There are three pages. First one is the interface. Second page you have A (1-6) and B (1-6) and C RIP OUT TO USE ON PROBLEM 6: 6. [15] Use the following Bounded

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site