Computers and Technology

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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:30, marmar72
Negative methods of behavior correction include all but this: sarcasm verbal abuse setting an example for proper behavior humiliation
Answers: 1
image
Computers and Technology, 23.06.2019 07:30, jackie0833
Which option allows you to view slides on the full computer screen?
Answers: 1
image
Computers and Technology, 23.06.2019 14:30, HarryPotter10
Open this link after reading about ana's situation. complete each sentence using the drop-downs. ana would need a minimum of ato work as a translator. according to job outlook information, the number of jobs for translators willin the future.
Answers: 3
image
Computers and Technology, 23.06.2019 15:00, victordhernandez01
Jake really works well with numbers and is skilled with computers but doesn't work well with others. which of the jobs discussed in this unit might be best for jake? why?
Answers: 3
Do you know the correct answer?
Consider the following class.

public class LightSequence
{
// attributes not...

Questions in other subjects:

Konu
Mathematics, 27.03.2021 18:50