Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class OpenMessage Object OpenMessage All Implemented Interfaces: Message public class OpenMessage extends Object implements Message Field Summary Fields Modifier and Type Field Description protected String

Class OpenMessage

Object

OpenMessage

All Implemented Interfaces:

Message

public class OpenMessage extends Object implements Message

Field Summary

Fields

Modifier and Type

Field

Description

protected String

body

protected String

from

protected String

subject

protected String

to

Constructor Summary

Constructors

Constructor

Description

OpenMessage(String to, String from, String subject, String body)

Method Summary

All MethodsInstance MethodsConcrete Methods

Modifier and Type

Method

Description

String

getBody()

Gets the body of the message

String

getFrom()

Gets the "from" portion of the message

String

getSubject()

Gets the subject of the message

String

getTo()

Gets the "to" portion of the message

boolean

search(String term, String part)

Searches for a particular term in a part of the message.

boolean

searchFrom(String term)

Searches for a message by "from" portion of the message.

boolean

searchSubject(String term)

Searches for a message by subject.

boolean

searchTo(String term)

Searches for a message by "to" portion of the message.

Methods inherited from class Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

to

protected String to

from

protected String from

subject

protected String subject

body

protected String body

Constructor Details

OpenMessage

public OpenMessage(String to, String from, String subject, String body)

Method Details

getBody

public String getBody()

Gets the body of the message

Specified by:

getBody in interface Message

Returns:

String body

getTo

public String getTo()

Gets the "to" portion of the message

Specified by:

getTo in interface Message

Returns:

String to

getSubject

public String getSubject()

Gets the subject of the message

Specified by:

getSubject in interface Message

Returns:

String subject

getFrom

public String getFrom()

Gets the "from" portion of the message

Specified by:

getFrom in interface Message

Returns:

String from

search

public boolean search(String term, String part)

Searches for a particular term in a part of the message. For example, if we were in a foreach loop and were looping through each message in the message list (m), and we reach the OpenMessage object that has the subject "Important Meeting" from Quick Rabbit, m.search("meeting", m.subject) should convert both term and part to lower case, and return true since the part, subject, contains the term.

Specified by:

search in interface Message

Parameters:

term - String term to check

part - Portion of OpenMessage to check in

Returns:

boolean value of the term being in the part (not worrying about case)

searchSubject

public boolean searchSubject(String term)

Searches for a message by subject. Tip: Remember your search() method you just implemented! You can call on that method to do the work for you. What arguments does search() take, and what variables do you have?

Specified by:

searchSubject in interface Message

Parameters:

term - term used to see if contained in subject

Returns:

boolean result if term was in the subject

searchTo

public boolean searchTo(String term)

Searches for a message by "to" portion of the message. Tip: Remember your search() method you just implemented! You can call on that method to do the work for you. What arguments does search() take, and what variables do you have?

Specified by:

searchTo in interface Message

Parameters:

term - term used to see if contained in "to" portion

Returns:

boolean result if term was in the "to" portion

searchFrom

public boolean searchFrom(String term)

Searches for a message by "from" portion of the message. Tip: Remember your search() method you just implemented! You can call on that method to do the work for you. What arguments does search() take, and what variables do you have?

Specified by:

searchFrom in interface Message

Parameters:

term - term used to see if contained in "from" portion

Returns:

boolean result if term was in the "from" portion

image text in transcribedimage text in transcribed

Ublic interface Message \{ 1 implementation String getBody(); 1 implementation String getTo(); 1 implementation String getsubject(); 1 implementation String getFrom(); 1 implementation boolean search(String term, String part); 2 usages 1 implementation boolean searchSubject(String term); 2 usages 1 implementation boolean searchTo(String term); 2 usages 1 implementation boolean searchFrom (string term)

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Every complete C + + program must have a function named brain.

Answered: 1 week ago