ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 8.00

The PhoneNumber class

Hello I need the following help with my problem set involving classes and the regexp class for regular expressions. . It must be done in Ruby

 

 

 

The PhoneNumber class will get you familiar with Ruby’s Regexp class for regular expressions.1. A DNA strand is represented by a string of the characters A, C, G, and T, each of which represents a nucleotide.The hamming distance between two DNA strands of the same length is equal to the number of positions in which theydiffer. Hamming distance is used in bioinformatics as a measure of the similarity of two strings. Write a DNA class thatgets initialized with a string of nucleotide characters. An instance of DNA responds to the to_s, length, andhamming_distance messages. Where a and b are DNA instances of the same length, the message senda.hamming_distance(b) returns the hamming distance between a and b:=> true>> dna1 = DNA.new('ATTGCC')=> ATTGCC>> dna1.length => 6>> puts dna1 ATTGCC>> dna2 = DNA.new('GTTGAC')=> GTTGAC>> dna1.hamming_distance(dna2)=> 2>> dna1.hamming_distance(dna1)=> 0>> dna1.hamming_distance(DNA.new('AT'))ArgumentError: dnas of different lengths from ass2.rb:17:in `hamming_distance' from (irb):8 fromC:/Ruby22/bin/irb:11:in ''2. Write a PhoneNumber class that gets initialized with a 10-digit phone number. In the call PhoneNumber.new(ph),the input ph take any of these possible formats:a 10-digit integera string of 10 digits(ddd) ddd-dddd where d is any digit [parenthesis format]ddd-ddd-dddd where d is any digit [hyphen format]Wherever whitespace appears in a string format, we can have a string of zero or more whitespace characters(including before and after the string as a whole). A PhoneNumber object responds to the to_s message whichreturns the number as a string in parenthesis format, and the area_code, prefix, and root messages which return theparts of the number in string format, as illustrated here:a = PhoneNumber.new(1234567890)puts a # (123) 456-7890puts a.area_code # 123puts a.prefix # 456

Attachments:

Answers

(11)
Status NEW Posted 22 May 2017 06:05 AM My Price 8.00

-----------

Not Rated(0)