I have created a functioning console menu and I will choose an option to add a new customer, as you can see below I have created the scanner to enter the details, what I dont know is how I would save the user input out to a text file called CustomerInformation. I can either do this with a function on this method or if there is some way to store the information and create a save function before I quit out of the console menu.
public void addCustomer()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter Name: ");
this.name = sc.nextLine();
System.out.print("Enter Address: ");
this.address = sc.nextLine();
System.out.print("Enter Gender(M or F): ");
this.gender = sc.nextLine();
System.out.print("Enter Date of Birth: ");
this.dob = sc.nextLine();
}
the whole customer class is:
import java.util.*;
import java.io.*;
public class Customer {
private String name;
private String address;
private String gender;
private String dob;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getDob() {
return dob;
}
public void setDob(String dob) {
this.dob = dob;
}
Customer (){
setName("Name");
setAddress("Address");
setGender("Gender");
setDob("dDob");
}
Customer (String strName, String strAddress, String strGender, String strDob, String strReport){
setName(strName);
setAddress(strName);
setGender(strGender);
setDob(strDob);
}
//Add Customer Function-------------------------------------------------------------------
public void addCustomer()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter Name: ");
this.name = sc.nextLine();
System.out.print("Enter Address: ");
this.address = sc.nextLine();
System.out.print("Enter Gender(M or F): ");
this.gender = sc.nextLine();
System.out.print("Enter Date of Birth: ");
this.dob = sc.nextLine();
}
//End Add Customer-------------------------------------------------------------------------
//Search Function-------------------------------------------------------------------------
//End Search Function-------------------------------------------------------------------
//Delete Customer Function ------------------------------------------------------
//End Delete Customer Function---------------------------------------------------------
//Save Progress Function--------------------------------------------------------------
//End Save Progress Function----------------------------------------------------------
public static int nextInt()
{
Scanner keyb = new Scanner(System.in);
int i = keyb.nextInt();
return i;
}
}