First, I want to thank you for helping if you did, if not, thanks for checking it anyway. Second, I have been working on this for awhile, and I am slowly making progress. I am to make an address book, and for the most part I am getting it done with out a hitch. I have 4 other classes besides these, but they are doing just fine. My problem is in my worker outFile.print(); statements. When I try and uncomment them, it tells me it can't find the symbol. When I insert PrintWriter outFile = new PrintWriter(outfile);, I still get the error. Thanks again for the assistance; I really appreciate it.
//DRIVER
import java.io.*;
import java.util.*;
class Project3
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
//Data Members
int answer;
answer = 0;
//Call constructor and set those variables as null
Address addressObject = new Address();
addressObject.street = "null";
addressObject.city = "null";
addressObject.state = "null";
addressObject.zip = "null";
//Menu print
System.out.println("1. Add a person to the address book.");
System.out.println("2. See if a person is in the address book.");
System.out.println("3. Print information of a specific person.");
System.out.println("4. Print names of persons having a birthday in a particular month.");
System.out.println("5. Print names of persons between two last names.");
System.out.println("6. Print names of persons having a particular status.");
System.out.println("7. Print the address book.");
System.out.println("8. Save the address book to disk.");
System.out.println("9. Load the address book from disk.");
System.out.println("10. Terminate the program.");
//Get data member to navigate menu
answer = console.nextInt();
//Switch to navigate menu
switch (answer)
{
case 1: addressObject.getbook();
addressObject.getaddress();
break;
case 2: //make method to search then print yes/no
break;
case 3: //make method to search then print that person
break;
case 4: System.out.println("No birthday was entered.");
break;
case 5: //make method to print ppl between 2 last names
break;
case 6: //make method to particular status
break;
case 7: addressObject.getbook(); //make a method to print
break;
case 8: addressObject.getaddress(); //getaddress is unfinished
break;
case 9: addressObject.getbook();
break;
case 10: System.exit(0);
break;
default: System.out.println("Enter a number between 1 and 10.");
}
}
}
then my worker
import java.io.*;
import java.util.*;
public class Address
{
//Declare variables
String street;
String city;
String state;
String zip;
String phone;
static Scanner console = new Scanner(System.in);
//Constructor
public Address(String st, String ct, String sta, String zp)
{
String street = st;
String city = ct;
String state = sta;
String zip = zp;
}
Address()
{
}
//Locate address book file
public void getbook()
{
//Declare variables
String infile;
String outfile;
//Get file locations
System.out.println("Enter location of the address book");
System.out.println("An example of this is C:hello.txt");
infile = console.next();
System.out.println("Enter location of the output file.");
outfile = console.next();
}
//Get address information
public void getaddress()
{
//Get address
System.out.println("Enter contact's Streetname as one word");
System.out.println("Example: 1111AmericanAvenue");
street = console.next();
//outFile.print(street);
System.out.println("Enter contact's city");
city = console.next();
//outFile.print(city);
System.out.println("Enter contact's state");
state = console.next();
//outFile.print(state);
System.out.println("Enter contact's zip");
zip = console.next();
//outFile.print(zip);
}
}