Eeo 224 object-oriented programming for electrical and


Assignment - Classes, Reference Variables and the String Class

1. Given an arbitrary ransom note, consisting of 15 - 20 words and several magazines, write a function that will return a true, if the ransom note can be constructed from the words in the magazines, otherwise it will return a false. Each word in the magazines can only be used once in your ransom note. The algorithm should work efficiently, such as, utilizing hash tables for storing and looking up strings. An example hash function maybe the sum of the ascii values of all the characters in the string, modulus an appropriate positive integer. For testing the code, utilize the ransom note and the magazines provided on the Black- board in files RansomNote.dat, Magazine1.dat, Magazine2.dat, Magazine3.dat, Magazine4.dat, Magazine5.datand Magazine6.dat.

In this problem, you will utilize the built in string class, its constructors, some of its methods and operators. For more on the string class, please refer to Prata, Chapter 16

2. Define, implement and test a Complex class, which has:
(a) At least two constructors.
(b) A destructor.
(c) Several Methods with functionality as described below:
- Returns real part.
- Returns imaginary part.
- Displays the number.
- Computes magnitude.
- Computes polar co-ordinates.
- Overloads operators +, -. * and /, with the corresponding operations.
- Overloads the operator ∼ for complex conjugate.
- Overloads the operators == and != for comparison.

The methods must make appropriate use of the reference variables, for arguments and re- turn types, as described in Prata, Chapter 10. For more details on operator overloading, refer to Prata, Chapter 11.

Discussion Board

There are points for participating in the Discussion Board. You are encouraged to ask questions on clarifying the assignments or related material, post your thoughts and some hints. Please do not post complete solutions.

Exercise Set

String class and Standard Template Libraries (STLs)
- Read in the six magazines from the files, one word at a time.
- Keep only the words, removing any punctuation or other characters.
- Store the words in a built-in STL container, such as array, vector or map.
- You are essentially building a repository of words.
- Design an algorithm for storing the words, such that you can easily find a word, without an exhaustive search through the repository.

Attachment:- Files.rar

Solution Preview :

Prepared by a verified Expert
Programming Languages: Eeo 224 object-oriented programming for electrical and
Reference No:- TGS02684909

Now Priced at $75 (50% Discount)

Recommended (97%)

Rated (4.9/5)