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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 09:00, king514
Technician a says that a new replacement part is always good. technician b says that sometimes recent repair work will be the cause of a complaint. who is correct? a. both technicians a and b b. technician a c. technician b d. neither technician a nor b
Answers: 3
image
Computers and Technology, 24.06.2019 10:20, silviamgarcia
Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should not be added to the list). these values entered by the user are added to a list we call 'initial_list'. then write a function that takes this initial_list as input and returns another list with 3 copies of every value in the initial_list. finally, inside print out all of the values in the new list. for example: input: enter value to be added to list: a enter value to be added to list: b enter value to be added to list: c enter value to be added to list: exit output: a b c a b c a b c note how 'exit' is not added to the list. also, your program needs to be able to handle any variation of 'exit' such as 'exit', 'exit' etc. and treat them all as 'exit'.
Answers: 2
image
Computers and Technology, 24.06.2019 18:30, HavenShort3075
These factors limit the ability to attach files to e-mail messages. location of sender recipient's ability to open file size of file type of operating system used
Answers: 1
image
Computers and Technology, 25.06.2019 03:00, samanthaurso1
Between 1932 and 1938, chester carlson developed a process that enabled a "picture" of a document to be taken and then have it reproduced on another
Answers: 1
You know the right answer?
Consider the following class.

public class LightSequence
{
// attributes not...

Questions in other subjects:

Konu
Social Studies, 27.07.2021 17:10