Need someone to write JAVADOC for this coding? ---------------------------------
ID: 3891864 • Letter: N
Question
Need someone to write JAVADOC for this coding?
----------------------------------------
package com.koothada;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
class Contact
{
String FirstName;
String LastName;
long PhoneNumber;
public Contact(String FirstName, String LastName,Long PhoneNumber)
{
this.FirstName=FirstName;
this.LastName=LastName;
this.PhoneNumber=PhoneNumber;
}
@Override
public String toString() {
return "Contact [FirstName=" + FirstName + ", LastName=" + LastName
+ ", PhoneNumber=" + PhoneNumber + "]";
}
}
public class ContactApp
{
public static void main(String[] args) throws FileNotFoundException
{
Scanner sc=new Scanner(System.in);
ArrayList<Contact>list=new ArrayList<Contact>();//create a Array list to Store All the Contact Details
File contact_details = new File ("F:\Workspace_Luna\Contactlist.txt");//Reading Contact details from the File
Scanner scanner = new Scanner(contact_details);
String Firstname,Lastname;
long Phone;
Contact contactlist;
while(scanner.hasNextLine())
{
Firstname = scanner.next();//Read First word of line in file as FirstName
Lastname = scanner.next();//Read Second word of line in a File as Second Name
Phone=scanner.nextLong();//Read the Third word of line as Phone Number
contactlist=new Contact(Firstname,Lastname,Phone);//Passing Input parameters through Constructor reading from the File.
//or Otherwise your wish Pass Arguments through the Constructor only
//like contactlist=new Contact("venkanna","Koothada",9949468557);
list.add(contactlist);
}
scanner.close();
System.out.println("The contact Details from the file is");
for(Contact obj:list)
{
System.out.println("FirstName: "+obj.FirstName+" LastName: "+obj.LastName+"PhoneNumber:"+obj.PhoneNumber);
}
//Or Use toString Method to print All the contact information.
//System.out.println(contactlist);
while(true)
{
System.out.println("*** Main Menu ****");
System.out.println("1.Add New Contact");
System.out.println("2.Search Contact");
System.out.println("3.Edit Contact");
System.out.println("4.Exit");
System.out.println("please Select any option");
int option=sc.nextInt();
boolean status = false;
switch(option)
{
case 1:
System.out.println("Please Enter Firstname:");
Firstname=sc.next();
System.out.println("Please enter LastName:");
Lastname=sc.next();
System.out.println("Please Enter MobileNumber");
Phone=sc.nextLong();
contactlist=new Contact(Firstname,Lastname,Phone);
list.add(contactlist);
System.out.println("New Contact Details Are Added Successfully");
break;
case 2:
System.out.println("Please Enter Phone Number");
Phone=sc.nextLong();
for(Contact obj:list)
{
if(Phone==obj.PhoneNumber)
{
status=true;
System.out.println("FirstName: "+obj.FirstName);
System.out.println("LastName: "+obj.LastName);
break;
}
}
if(status==false)
System.out.println("Contact Details are not found");
break;
case 3:
System.out.println("Please Enter Phone Number");
Phone=sc.nextLong();
for(Contact obj:list)
{
if(Phone==obj.PhoneNumber)
{
status=true;
System.out.println("FirstName: "+obj.FirstName);
System.out.println("LastName: "+obj.LastName);
System.out.println("Please Enter New Mobile/Phone Number:");
Phone=sc.nextLong();
obj.PhoneNumber=Phone;
System.out.println("New Phone Number Updated Successfully");
break;
}
}
if(status==false)
System.out.println("Contact Details are not found");
break;
case 4:
System.out.println("Terminated Successfully");
System.exit(0);
default:
System.out.println("Invalid Option please try again");
}
sc.close();
}
}
}
Explanation / Answer
Please find the JAVADOC for the following code:-
package com.koothada;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
/**
* @author gmalaker
* @version 1.0
*/
class Contact {
String FirstName;
String LastName;
long PhoneNumber;
/**
* @param FirstName - the First name of Contact
* @param LastName - the Last name of Contact
* @param PhoneNumber - the PhoneNumber of Contact
*/
public Contact(String FirstName, String LastName, Long PhoneNumber) {
this.FirstName = FirstName;
this.LastName = LastName;
this.PhoneNumber = PhoneNumber;
}
/**
* @return String
*/
@Override
public String toString() {
return "Contact [FirstName=" + FirstName + ", LastName=" + LastName + ", PhoneNumber=" + PhoneNumber + "]";
}
}
public class ContactApp {
/**
* @param args
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(System.in);
ArrayList<Contact> list = new ArrayList<Contact>();// create a Array
// list to Store All
// the Contact
// Details
File contact_details = new File("F:\Workspace_Luna\Contactlist.txt");// Reading
// Contact
// details
// from
// the
// File
Scanner scanner = new Scanner(contact_details);
String Firstname, Lastname;
long Phone;
Contact contactlist;
while (scanner.hasNextLine()) {
Firstname = scanner.next();// Read First word of line in file as
// FirstName
Lastname = scanner.next();// Read Second word of line in a File as
// Second Name
Phone = scanner.nextLong();// Read the Third word of line as Phone
// Number
contactlist = new Contact(Firstname, Lastname, Phone);// Passing
// Input
// parameters
// through
// Constructor
// reading
// from the
// File.
// or Otherwise your wish Pass Arguments through the Constructor
// only
// like contactlist=new Contact("venkanna","Koothada",9949468557);
list.add(contactlist);
}
scanner.close();
System.out.println("The contact Details from the file is");
for (Contact obj : list) {
System.out.println(
"FirstName: " + obj.FirstName + " LastName: " + obj.LastName + "PhoneNumber:" + obj.PhoneNumber);
}
// Or Use toString Method to print All the contact information.
// System.out.println(contactlist);
while (true) {
System.out.println("*** Main Menu ****");
System.out.println("1.Add New Contact");
System.out.println("2.Search Contact");
System.out.println("3.Edit Contact");
System.out.println("4.Exit");
System.out.println("please Select any option");
int option = sc.nextInt();
boolean status = false;
switch (option) {
case 1:
System.out.println("Please Enter Firstname:");
Firstname = sc.next();
System.out.println("Please enter LastName:");
Lastname = sc.next();
System.out.println("Please Enter MobileNumber");
Phone = sc.nextLong();
contactlist = new Contact(Firstname, Lastname, Phone);
list.add(contactlist);
System.out.println("New Contact Details Are Added Successfully");
break;
case 2:
System.out.println("Please Enter Phone Number");
Phone = sc.nextLong();
for (Contact obj : list) {
if (Phone == obj.PhoneNumber) {
status = true;
System.out.println("FirstName: " + obj.FirstName);
System.out.println("LastName: " + obj.LastName);
break;
}
}
if (status == false)
System.out.println("Contact Details are not found");
break;
case 3:
System.out.println("Please Enter Phone Number");
Phone = sc.nextLong();
for (Contact obj : list) {
if (Phone == obj.PhoneNumber) {
status = true;
System.out.println("FirstName: " + obj.FirstName);
System.out.println("LastName: " + obj.LastName);
System.out.println("Please Enter New Mobile/Phone Number:");
Phone = sc.nextLong();
obj.PhoneNumber = Phone;
System.out.println("New Phone Number Updated Successfully");
break;
}
}
if (status == false)
System.out.println("Contact Details are not found");
break;
case 4:
System.out.println("Terminated Successfully");
System.exit(0);
default:
System.out.println("Invalid Option please try again");
}
sc.close();
}
}
}
Please let me know in case of any clarifications required. Thanks!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.