subject

Consider the following class.

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 */ }
}

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.

Write the code segment below. Your code segment should meet all specifications and conform to the examples.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 18:30
How often does colleges update the cost of attendance on their website? . a)every two years b) every four years c) every year d) every semester
Answers: 1
question
Computers and Technology, 23.06.2019 22:00
Technician a says engine assemblies can be mounted longitudinally in a chassis. technician b says engine assemblies can be mounted transversely in a chassis. who is correct?
Answers: 2
question
Computers and Technology, 24.06.2019 00:20
Describe a data structures that supports the stack push and pop operations and a third operation findmin, which returns the smallest element in the data structure, all in o(1) worst-case time.
Answers: 2
question
Computers and Technology, 24.06.2019 00:40
What is the error in the following pseudocode? module main() call raisetopower(2, 1.5) end module module raisetopower(real value, integer power) declare real result set result = value^power display result end module
Answers: 1
You know the right answer?
Consider the following class.

public class LightSequence
{
// attributes not...
Questions
Questions on the website: 13722367