Define class that contains member variable of type string

Assignment Help Programming Languages
Reference no: EM1360350

Define a class named Document that contains a member variable of type String named text that stores any textual content for the document. Create a method named toString that returns the text field and also include a method to set this value.

Next, define a class for Email that is derived from Document and includes member variables for the sender, recipient, and title of an email message. Implement appropriate accessor and mutator methods. The body of the email message should be stored in the inherited variable text. Redefine the toString method to concatenate all text fields.

Similarly, define a class for File that is derived from Document and includes a member variable for the pathname. The textual contents of the file should be stored in the inherited variable text. Redefine the toString method to concatenate all text fields.

Finally, create several sample objects of type Email and File in your main method. Test your objects by passing them to the following subroutine that returns true if the object contains the specified keyword in the text property.

public static boolean containsKeyword(Document docObject, String keyword)
{
if (docObject.toString().indexOf(keyword,0) >= 0)
return true;
return false;
}
}

Reference no: EM1360350

Questions Cloud

Differences between self-efficacy and self-esteem : Trying to understand an explanation of the differences between self-efficacy and self-esteem. Provide two examples of when self-esteem might be misinterpreted as self-efficacy and explain why.
Possible reasons for outliers and possible solutions : Expalin what are possible reasons for outliers and possible solutions
Compute the maturity risk premium : Key's Corporation's five year bonds yield 6.50% and five year T-bonds yield 4.40%. The real risk free rate is 2.5%, the default risk premium for Key's bond is DRP is 0.40%,
Self-efficacy theory : A description of a personal situation in a learning environment in which self-efficacy enhanced your motivation. Use self-efficacy theory to support your response.
Define class that contains member variable of type string : Define a class named Document that contains a member variable of type String named text that stores any textual content for the document.
Percentage change in productivity : Show what is the percentage change in productivity from October to November
Compute and answer parts a through : Compute and answer parts a through and Include all calculations and spreadsheets in your post
Explain margin buying of common stocks : Discuss and explain margin buying of common stocks. Include in your discussion the advantages and disadvantages, the types of margin requirements,
Illustrate what would happen to aggregate demand. : Government increases taxes by 50 billion and increase transfer payments by 50 billion illustrate what would happen to aggregate demand.

Reviews

Write a Review

Programming Languages Questions & Answers

  Using the irvine32 library functions

Create 32 random points which have (x, y) co-ordinates

  Write pseudocode and flowchart for program

Write pseudocode and flowchart for program that will prompt the user for a number, prompt the user for an operator (+,-,*,/).

  Php script to obtain url and its description from user

Write a PHP script to obtain URL and its description from user and stores information into database by using MySQL.

  Method to pass string argument and returns first line

Write a method, getFirstLine, that is passed a String argument and that returns the first line.

  Design a math sorting game

Using Visual Studio 2010, design a math sorting game. A random number between 1 and 99 will be generated and displayed to the user. User will quickly have to divide that number by 3, and come up with remainder.

  Program to read an employee-s number from keyboard

Write a program that reads an employee's number from the keyboard, number of hours worked and an hourly rate of pay.

  Php code to add-delete product using ajax programming

PHP Code to add a new product and delete a existing product Implement AJAX Programming based solutions to write code to add a new product to the database.

  Use-professional translator in creting website-other country

When and why would you need to use the services of a professional translator to help prepare your website for an audience in another country?

  Write a script to declares and sets variable

Write a script that declares and sets a variable thats equal to the total outstanding balance due. If that balance due is greater than $10,000.00.

  Evaluate the fibonacci series

Write a program to evaluate the first 20 numbers of Fibonacci series.

  Statement to read variables of type double

Suppose two variables p1 and p2 of type POINT, with two fields, x and y, both of type double, have been declared. Write a statement that reads values for p1 and p2 in that order.

  Write function to take the name of file as one parameter

Write a function named paragraphStats() that takes one parameter:the name of a file. The file contains a single line of text.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd