I'm working on a manage friend list program which allow you to add friends, remove friend from list, and display friend list. I have not finish this program yet. But I keep getting compile error at line 42 which I'm trying to create a method allow user to enter name and age of their friends and pass the value to the arraylist. I can't figure out where I did wrong. Thank you so much
Here is the code.
public class Friends
{
private String name;
private int age;
public Friends(String friendName, int friendAge)
{
name = friendName;
age = friendAge;
}
public void setName(String friendName)
{
name = friendName;
}
public void setAge(int friendAge)
{
age = friendAge;
}
public String getName()
{
return name;
}
public int getAge()
{
return age;
}
}
//Friend List
//Chia-Chao Liu
// 4/12/2001
//The purpose of this class is
//to add friends and remove friends,
//and display all friends.
import java.util.ArrayList;
import java.util.Scanner;
public class FriendsList
{
ArrayList <Friends> fName = new ArrayList <Friends> ();
ArrayList <Friends> fAge = new ArrayList <Friends> ();
Scanner input = new Scanner(System.in);
public FriendsList()
{
int choose;
System.out.println("1. Add a friend");
System.out.println("2. Remove a friend");
System.out.println("3. Display Friend List");
System.out.println("4. Exist");
System.out.println("Please Enter the choose option: ");
choose = input.nextInt();
switch (choose)
{
case '1' :
break;
case '2' :
break;
case '3' :
break;
case '4' :
break;
default:
}
public void addfriends()
{
String name;
int age;
System.out.println("Please Enter the Name: ");
name = input.next();
add.fName(name);
System.out.println("Please Enter the age: ");
age = input.nextInt();
}
}