Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA The objective of the code is to produce this output: ////////////output////////////////////////////// Program to assign leads to users 0. Quit 1. Add a lead 2.

JAVA

The objective of the code is to produce this output:

////////////output//////////////////////////////

Program to assign leads to users

0. Quit

1. Add a lead

2. Add a user

3. Assign leads

4. Display leads

Please choose a cmd (0-4): 1

Please enter a name for the lead: Jane Doe

Please enter an email contact for the lead: jdemail.com

Please enter the country where the lead is located: USA

0. Quit

1. Add a lead

2. Add a user

3. Assign leads

4. Display leads

Please choose a cmd (0-4): 1

Please enter a name for the lead: Mark Spence

Please enter an email contact for the lead: mmsfakemail.com

Please enter the country where the lead is located: UK

0. Quit

1. Add a lead

2. Add a user

3. Assign leads

4. Display leads

Please choose a cmd (0-4): 4

Name Country Email Assigned User

-----------------------------------------------------------------

Jane Doe USA jdemail.com

Mark Spence UK msfakemail.com

0. Quit

1. Add a lead

2. Add a user

3. Assign leads

4. Display leads

Please choose a cmd (0-4): 2

Please enter a name for the user: Dora Singh

Is the user online? (true/false) true

0. Quit

1. Add a lead

2. Add a user

3. Assign leads

4. Display leads

Please choose a cmd (0-4): 2

Please enter a name for the user: Fred Ho

Is the user online? (true/false) true

0. Quit

1. Add a lead

2. Add a user

3. Assign leads

4. Display leads

Please choose a cmd (0-4): 3

0. Quit

1. Add a lead

2. Add a user

3. Assign leads

4. Display leads

Please choose a cmd (0-4): 4

Name Country Email Assigned User

-----------------------------------------------------------------

Jane Doe USA jdemail.com Dora Singh

Mark Spence UK msfakemail.com Fred Ho

0. Quit

1. Add a lead

2. Add a user

3. Assign leads

4. Display leads

Please choose a cmd (0-4): 0

////////////////////end of output///////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////

code:

package crm;

import java.util.Scanner;

import java.util.List;

import java.util.ArrayList;

public class Lead {

private String name;

private String email;

private String country;

private User assignedUser;

public Lead(String name, String email, String country) {

this.name = name;

this.email = email;

this.country = country;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getEmail() {

return email;

}

public void setEmail(String email) {

this.email = email;

}

public String getCountry() {

return country;

}

public void setCountry(String country) {

this.country = country;

}

public User getAssignedUser() {

return assignedUser;

}

public void setAssignedUser(User assignedUser) {

this.assignedUser = assignedUser;

}

}

public class User {

private String name;

private boolean isOnline;

private List assignedLeads;

public User(String name, boolean isOnline) {

this.name = name;

this.isOnline = isOnline;

this.assignedLeads = new ArrayList<>();

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public boolean isOnline() {

return isOnline;

}

public void setOnline(boolean online) {

isOnline = online;

}

public List getAssignedLeads() {

return assignedLeads;

}

///////////////////////////////////////////////////////////////

details on how to set up the class:

1. All classes should be in the crm package, which, means all files need to be in the crm folder (usually under the src folder)

Lead class:

a. Stores the name, email contact, country and the current assigned user for this lead (see next item)

User class

a. Stores user name, whether user is online or not, and a list of Leads assigned to this user

AssignLeads class:

a. Stores a List of Leads and a List of Users, but just in memory.

b. Supports operations to:

i. Add a lead Javas Scanner class has useful features for reading in different types of values, including whole lines of text to cover input with spaces

1. The functions that just read the next word (whether as a String or some other type like int) stop at the first character that is not part of the word, so there is often a newline still in the input stream after reading one of these. Use Scanners nextLine() to skip past the end of the current line.

ii. Add a user

iii. Assign users to leads who do not have an assigned user

iv. Display info on the leads

v. Quit the program

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

Students also viewed these Databases questions

Question

b. Why were these values considered important?

Answered: 1 week ago