Question: Core Java_OOPS Concept_Problem Statement1 Benjamin started a Mobile Accessories and Gadgets Shop in his City. Youngsters today are more attracted towards gadgets, the reason why

Core Java_OOPS Concept_Problem Statement1

Benjamin started a Mobile Accessories and Gadgets Shop in his City. Youngsters today are more attracted towards gadgets, the reason why Benjamin chose to invest in this industry. Undoubtedly he had a decent customer base visiting his shop everyday. To ease his job in maintaining the details of his Users, he wantedan automated system that will search a specific User detail based on two search types - one search using Username and the other search using Firstname and Lastname and display the details of that User. One of the key benefits of using Object-Oriented Programming is Method Overloading. Method Overloading is the ability to create multiple methods of the same name in the same class with different implementations. Write a program using Method Overloading concept using two methods that will help Benjamin to search User details, one search using Username and the other using Firstname and Lastname. Create a class named User with the following private member variables / attributes.

String userName

String firstName

String lastName

String contact

Include a 4-argument argument constructor with following order userName,firstName,lastName,contact. Include appropriate getters,setters and default constructor This class includes the following methods:

No

Method Name

Description

1

User findUser(User userArray[],String userName)

In this method, find the appropriate user by username and return the user object, otherwise return null.

2

User findUser(User userArray[],StringfirstName,String lastName)

In this method, find the appropriate user by firstname and lastname and return the user object, otherwise return null.

Create a Main class to access the above class methods and display the user details.

[Note :Strictly adhere to the object oriented specifications given as a part of the problem statement.Use the same class names, attribute names and method names.] Input and Output Format: If the user is not present display 'User not found' Refer sample input and output for formatting specification. [All text in bold corresponds to input and the rest corresponds to output.] Sample Input and Output 1: Enter the total number of users 2 Enter user details peeter,peeter,mark,9965000001 john,john,sam,9500484444 1)Search user by user name 2)Search user by first name and last name Enter your option 1 Enter the user name to search peeter User details : Username :peeter FirstName :peeter LastName :mark Contact :9965000001 Sample Input and Output 2: Enter the total number of users 1 Enter user details suriya,suriya,sivakumar,9966554433 1)Search user by user name 2)Search user by first name and last name Enter your option 1 Enter the user name to search sivakumar User not found

Here I am providing the piece of code. Please update in that format and send me back.

User.Java

public class User {

private String userName; private String firstName; private String lastName; private String contact;

public User(String userName, String firstName, String lastName, String contact) { this.userName = userName; this.firstName = firstName; this.lastName = lastName; this.contact = contact; }

User() {}

public String getUserName() { return userName; }

public void setUserName(String userName) { this.userName = userName; }

public String getFirstName() { return firstName; }

public void setFirstName(String firstName) { this.firstName = firstName; }

public String getLastName() { return lastName; }

public void setLastName(String lastName) { this.lastName = lastName; }

public String getContact() { return contact; }

public void setContact(String contact) { this.contact = contact; } //fill your code }

Main.Java

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main {

public static void main(String[] args) throws IOException {

//fill your code } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!