Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here's Assignment4.java import java.util.*; public class Assignment4 { public static void main (String[] args) { // local variables, can be accessed anywhere from the main

Here's Assignment4.java import java.util.*; public class Assignment4 { public static void main (String[] args) { // local variables, can be accessed anywhere from the main method char input1 = 'Z'; String inputInfo; String projTitle, projLocation, first, last, projNumStr, deptNumStr; int projNumber, deptNum; String line = new String(); // instantiate a Project object Project project1 = new Project(); printMenu(); //Create a Scanner object to read user input Scanner scan = new Scanner(System.in); do // will ask for user input { System.out.println("What action would you like to perform?"); line = scan.nextLine(); if (line.length() == 1) { input1 = line.charAt(0); input1 = Character.toUpperCase(input1); // matches one of the case statement switch (input1) { case 'A': //Add Project System.out.print("Please enter the Project information: "); System.out.print("Enter its title: "); projTitle = scan.nextLine(); project1.setProjTitle(projTitle); System.out.print("Enter its project number: "); projNumStr = scan.nextLine(); projNumber = Integer.parseInt(projNumStr); project1.setProjNumber(projNumber); System.out.print("Enter its location: "); projLocation = scan.nextLine(); project1.setProjLocation(projLocation); System.out.print("Enter its manager's first name: "); first= scan.nextLine(); System.out.print("Enter its manager's last name: "); last = scan.nextLine(); System.out.print("Enter its manager's department number: "); deptNumStr = scan.nextLine(); deptNum = Integer.parseInt(deptNumStr); project1.setProjManager(first, last, deptNum); break; case 'D': //Display project System.out.print(project1); break; case 'Q': //Quit break; case '?': //Display Menu printMenu(); break; default: System.out.print("Unknown action "); break; } } else { System.out.print("Unknown action "); } } while (input1 != 'Q' || line.length() != 1); } /** The method printMenu displays the menu to a user **/ public static void printMenu() { System.out.print("Choice\t\tAction " + "------\t\t------ " + "A\t\tAdd Project " + "D\t\tDisplay Project " + "Q\t\tQuit " + "?\t\tDisplay Help "); } } Program Description Class Diagram: Assignment #4 will be the construction of 2 new classes and a driver program (the class containing a main method). Manager class The Manager class describes information of departure or arrival of a project. It has following attributes: Attribute name Attribute type Description firstName String The first name of the manager lastName String The last name of the manager deptNum String The department number of the manager The following constructor should be provided to initialize each attribute. This constructor initializes the value of string attributes to "?" and the value of integer attribute to 0. public Manager( ) The following accessor methods should be provided to get the attributes: public String getFirstName() public String getLastName() public int getDeptNum() The following modifier(mutator) methods should be provided to set the attributes: public void setFirstName(String someFirstName) public void setLastName(String someLastName) public void setDeptNum(int someDeptNum) The following method must be defined: public String toString() toString method should return a string of the following format: Mary Poppins, Dept Num:8 where "Mary" is a first name, "Poppins" is a last name, and "8" is the department number. So you need to insert "," or a string between these variables. Note that you can choose a meaningful parameter variable name for each method. Project class The Project class describes a project within an institution. It has the following attributes: Attribute name Attribute type Description projTitle String The title of the project. projNumber int The project number projLocation String The location of the project. projManager Manager The manager of the project The following constructor should be provided to initialize each attribute. This constructor initializes the value of string attributes to "?" and the value of integer attribute to 0, and an object of Manager using the constructor of the Manager class. public Project( ) The following accessor methods should be provided to get the attributes: public String getProjTitle() public int getProjNumber() public String getProjLlocation() public Manager getProjManager() The following modifier(mutator) methods should be provided to change the attributes: public void setProjTitle(String aTitle) public void setProjNumber(int number) public void setProjLocation(String aLocation) public void setProjManager(String someFirstName, String someLastName, int someDeptNum) The following method must be defined: public String toString() The toString() method constructs a string of the following format: Project Title:\t\tFarming Project Project Number:\t\t15 Project Location:\tPhoenix Project Manager:\tMary Poppins, Dept Num:8

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_2

Step: 3

blur-text-image_3

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

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

Find h(0), h(2), and h(- x) for h(x) = x + x2 - 1.

Answered: 1 week ago

Question

What is brainstorming?

Answered: 1 week ago

Question

9. What is the first step in writing a formal report?

Answered: 1 week ago