Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Part A Create a class CompanyDoc, representing an official document used by

ID: 673775 • Letter: J

Question

Java

Part A Create a class CompanyDoc, representing an official document used by a company. Give it a String title and an int length. Throughout the class, use the this. notation rather than bare instance variables and method calls. Add a default constructor. Add a parameterized constructor that takes a value for title. Use this( appropriately to call one constructor from another. Add a toString(), which returns a string with the title, and the length in parentheses. So it might look like: Employment Turnover Report (16342) Add a method longer( with return type boolean, which takes a CompanyDoc as parameter. doc1.longer(doc2) returns true if doc1's length is greater than doc2's length, false otherwise. Part B Create a class Employee with an instance variable for name and instance variable currentDoc of type CompanyDoc. To CompanyDoc, also add an instance variable author of type Employee. In Employee, in the mutator for currentDoc, make sure that when a CompanyDoc becomes an employee's currentDoc, the employee becomes the author of the document as well. In Employee, add a method swapDocs( which takes another Employee and has them swap their currentDocs. Part C Create a class DocRepository with one instance variable of type Employee, currentEmployee Add a method menu that presents a menu-driven interface as follows: Main menu -- user can either create an employee or end the program If they create an employee, ask for the name, create an employee with that name (henceforth, the current employee) , and go to Employee Menu. (Do this even if a current employee was created previously) Employee menu -- user can create a document, edit document, view document, return to the main menu, or quit the program If they ask to create a document, what we want to do is ask for the title, create that document, and make it the current employee's current document. First, however, check whether the current employee has a current document. If not, just go ahead. If they have one, first check if they want to replace it, and only do so if they say yes. After this, return to the Employee Menu If they edit the document, first check if the current employee has a document. If not, complain and return to the Employee menu. If so, go to the Document menu. If they view the document, simply print the current document. Document menu -- user can add words, remove words, return to the Employee menu, return to the main menu, or quit the program. If the user adds words, ask how many, and add that to the length of the current document. If the user removes words, check that there are at least that many words in the current document. If so, subtract that from the length, otherwise complain and return to the Document menu. In a separate main, create a DocRepository and have it start its menu. EC+10 Use a single large nested loop structure to do this, and, using labeled breaks, add the ability to quit the program from any one of these menus, or return to the main menu from any of the submenus. (hint: you are in a class, you have instance variables.)

Explanation / Answer

Solution :

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote