Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve 1,2,3,4 Exercise home number 8 Study material for the exercise: Recursion In this exercise it is forbidden to use loops. A solution with

please solve 1,2,3,4 image text in transcribed
image text in transcribed
Exercise home number 8 Study material for the exercise: Recursion In this exercise it is forbidden to use loops. A solution with loops will not be accepted. In terms of working with the String class, only methods, (charAt 0.indexOf .length ( substring 0 Question 1 (100%) Write a class called Dna Sequence which represents a sequence of DNA (DNA). DNA is the genetic material that appears in every living cell. From our point of view, this is a string consisting of only 4 letters: M, A, C, G (lower or upper case). A valid DNA sequence contains only these letters. These letters are called nucleotides. Studies in genetics and bioinformatics analyze such sequences and compute a variety of statistics. For example, we would like to calculate how many times each letter appears in the sequence. Fields The class contains two private fields: a. sequence - the DNA sequence that the class represents (String type) B. nucleotideCounts - A one-dimensional array of integers that counts how many times each letter appears in the sequence. The first place counts how many times the letter A (small or large) appears, the second place counts how many times the letter C (small or large) appears, the third place counts how many times the letter G (small or large) appears, and the fourth place counts how many times the letter T appears (Small or large). Constructors 1. An empty constructor which initializes the sequence sequence to be "ACGT" and the array accordingly. Builder Signature: public DnaSequence o 2. A builder who gets a sequence. If it is a valid DNA sequence, it initializes both fields accordingly. Otherwise, the initialization is done as in the blank constructor. Builder signature: public Dna Sequence (String sequence) 3. Copy builder: public Dna Sequence (Dna Sequence other) Methods 1. get methods for the fields: public String getSequence () public int I getNucleotideCounts 0 2. Set method for the sequence: public void set Sequence (String sequence) Notes: 1. Depending on the sequence update, the counts field must also be updated according to the new sequence 2. The update is performed only if the sequence parameter is a valid DNA sequence. Otherwise, the function does not change the object. 3. A static method that receives a string and checks whether it is a valid DNA sequence. Signature of the method: public static boolean isDna Sequence (String sequence) 4. A method that turns each small letter in sequence into a capital letter and vice versa. Signature of the method: public void changeCapitalization 5. A static method that accepts 2 arrays and adds the second to the first, without changing the second. If one of the arrays is null or the arrays are not the same length, the method returns false. Otherwise, true will be returned. Signature method: public static boolean addArray (int arri, int ( arr2) 6. A method that chains a DNA sequence at the end of the sequence of this. In addition, the method updates the counts using the method from section 5. Signature of the method: public void concatGenes (Dna Sequence other) 7. The toString method, which returns string production for the object, contains the same sequence information and about the counts in the format: , , , ) Where is the number of occurrences of "A" or "a", etc. For example, for an object representing the "ACGT" sequence the string would be: ACGT: (1, 1, 1, 1) Method signature: public String toString()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions