Programação Java I
Por: liperibeiro2015 • 15/4/2015 • Trabalho acadêmico • 256 Palavras (2 Páginas) • 224 Visualizações
import javax.swing.JOptionPane;
import java.util.Scanner;
public static void main(String args[])
{
Execute();
}
private static void Menu()
{
System.out.println("1 - New contact"");
System.out.println("2 - Show contacts");
System.out.println("3 - Delete one contact");
System.out.println("4 - Exit \n\n");
}
private static void Contact()
{
public String Name { get; set;}
public String Email { get; set;}
public String Phone { get; set;})
}
private static void InsertContact(List<Contact> contacts)
{
var person = new Contact();
Scanner scan = new Scanner(System.in);
System.out.println("Enter contact name: ");
person.Name = scan(nextLine);
System.out.println("Enter contact email: ");
person.Email = scan(nextLine);
System.out.println("Enter contact phone");
person.Phone = scan(nextLine);
contacts.Add(person);
}
private static void ShowContacts(List<Contact> contacts)
{
for(int i = 0; i < contacts.Counter; i++)
{
System.out.println(contacts[i]);
}
}
private static void Delete(List<Contact> contacts)
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter contact name for delete");
String name = scan(nextLine);
var person = contacts.Find(c => c.Name == name);
if (person != null)
{
contacts.Delete(person);
System.out.println(person.Name + " has been deleted");
return;
}
...