GIVEN THE CODE BELOW Given the following class: /** * Document class. */ public class Document { private int words; /** * constructor *...

50.1K

Verified Solution

Question

Programming

GIVEN THE CODE BELOW
Given the following class:
/**
* Document class.
*/
public class Document {
private int words;
/**
* constructor
* pre: none
* post: A Document object created. Words initialized to 0.
*/
public Document() {
words = 0; //default words
}
/**
* Changes the number of document words.
* pre: none
* post: Words has been changed.
*/
public void setWords(int numWords) {
words = numWords;
}

/**
* Calculates the number of pages.
* pre: none
* post: The number of pages has been returned.
*/

public int calculatePages() {
final int WORDS_PER_PAGE = 300;
int pages;
pages = words / WORDS_PER_PAGE;
if (words % WORDS_PER_PAGE > 0) {
pages += 1;
}   
return(pages);
}

/**
* Returns the number of words in a document.
* pre: none
* post: The number of document words has been returned.
*/
public int getWords() {
return(words);
}
}


Create an Essay class that inherits the Document class. The Essayclass should include member constants MIN_WORDS andMAX_WORDS.
An essay should be between 1500 and 3000 words. The Essay classshould also contain
a member method validLength(), which returns true when the Essayobject contains between MIN_WORDS and MAX_WORDS and falseotherwise.
**Create an EssayAssignment application that tests the Essay class.EssayAssignment will contain the main() method.

Answer & Explanation Solved by verified expert
4.0 Ratings (472 Votes)
Program Document class public class Document private int words constructor pre none post A Document object created Words initialized to 0 public Document words 0 default words Changes the number of document    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students