76.2k views
5 votes
Apcs question is very confusing. Given this code:

public class LightSequence

{

// attributes not shown



/** The parameter seq is the initial sequence used for

* the light display

*/

public LightSequence(String seq)

{ /* implementation not shown */ }



/** Inserts the string segment in the current sequence,

* starting at the index ind. Returns the new sequence.

*/

public String insertSegment(String segment, int ind)

{ /* implementation not shown */ }



/** Updates the sequence to the value in seq

*/

public void changeSequence(String seq)

{ /* implementation not shown */ }



/** Uses the current sequence to turn the light on and off

* for the show

*/

public void display()

{ /* implementation not shown */ }

}

the question is
Assume that the string oldSeq has been properly declared and initialized and contains the string segment. Write a code segment that will remove the first occurrence of segment from oldSeq and store it in the string newSeq. Consider the following examples.

If oldSeq is "1100000111" and segment is "11", then "00000111" should be stored in newSeq.
If oldSeq is "0000011" and segment is "11", then "00000" should be stored in newSeq.
If oldSeq is "1100000111" and segment is "00", then "11000111" should be stored in newSeq.

User Andyfinch
by
4.5k points

1 Answer

3 votes
Sorry is this a question? If it is a question I don’t know the answer....
User Westse
by
5.2k points