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

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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