hello, im doing a project on email account which must include at least 2 constructors, a finaliser, a display method()
, a menu that allows to test all fuctions of the class and a main()
i got the attributes of email : address, password, currentName, noOfmails
and the methods are logine(), inputPassword(), validateUser(), changePassword(), validate(), receiveMail(), deleteMail(), deleteAllMail()
My program is as follows, pls do check
//project: email account
//date:03/October 2005
import java.io.*;
public class EmailAccount
{
public String address;
public String password;
private String currentName;
private int noOfMails;
//default constructor of the Email Account
public EmailAccount()
{
address="nishad@intnet.mu";
password="flower ";
currentName="Nishad";
noOfMails=0;
}//the end of constructor
//overloaded constructor
public EmailAccount(String add,String pass,String cName,int numMails)
{
this.address=add;
this.password=pass;
this.currentName=cName;
this.noOfMails=numMails;
}
//to initialise address
public void setAddress()throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the address :");
address=input.readLine();
}
//to initialise password
public void setInputPassword()throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter your password :");
String InputPassword=input.readLine();
System.out.print("\n");
//password can be a minimum of 6 letters
//if(InputPassword == null)
// return false;
// else if(InputPassword.length()<6)
// return false;
// else
// return true;
}
//gettors
public String getAddress()
{
return address;
}
public String getInputPassword()
{
return password;
}
public String getCurrentName()
{
return currentName;
}
public int getNoOfMails()
{
return noOfMails;
}
//user login in the system
public void login()throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Are u a member ? Yes or no ");
String login=input.readLine();//read login name from keyboard
System.out.print("\n");
if(login.compareTo("yes")>=0)
{
System.out.print("You can enter the system :");
System.out.print("\n");
}
else
{
System.out.print("you are not allowed to enter :");
System.exit(0);//exit from the system
}
//return login;
}
public void address() throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter your address here :" );
String address =input.readLine();
System.out.print("\n");
}
public void inputPassword()throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter your password here:");
String inputPassword=input.readLine();
System.out.print("\n");
}
//validate if the user has enter the correct address and password
public void ValidateUser()throws IOException
{
for(int i=1; i<3;i++)
{
if((address.compareTo("nishad@intnet.mu")==0)&&(password.compareTo("Flower")==0))
System.out.println("Login correct");
else
{
System.out.println("ERROR : Try again"+"\n");
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter your address here :" );
String address =input.readLine();
System.out.print("Enter your password here:");
String inputPassword=input.readLine();
}
}
System.out.println("Sorry access is denied. ");
System.exit(0);
}
/* public void tryAgain()throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter your address here :" );
String address =input.readLine();
System.out.print("Enter your password here:");
String inputPassword=input.readLine();
}*/
//to change the password of the user
public String changePassword()throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter password:");
String changepassword=input.readLine();
password= changepassword;
return password;
}
public void validate()
{
}
//mail increases by one
public void receiveMail(int numMail)
{
numMail+=1;
}
//mail decreases by one
public void deleteMail(int numMail)
{
numMail-=1;
}
//delete all mails in the inbox
public void deleteAllMails(int numMail)
{
numMail=0;
System.out.println("Delete all mails in the inbox:"+numMail);
}
//deleting all mails from the system
public void Finalize()
{
System.out.println("All mails are going to be deleted permanently");
}
//menu
public void menu()throws IOException
{
while(true)
System.out.println("Menu for the Email Account");
System.out.println("1: Login the system");
System.out.println("2: Input the password");
System.out.println("3: validate the user");
System.out.println("4: Change password!");
System.out.println("5: Again validate");
System.out.println("6: Receive mails");
System.out.println("7: Delete mail");
System.out.println("8: Delete all mails from the inbox");
System.out.println("9: Exit");
System.out.println("10: Input choice");
//converting a string to an integer
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
int choice=Integer.parseInt(input.readLine());
switch(choice)
{
case 1: this.login();
case 2: this.setInputPassword();
case 3: this.ValidateUser();
case 4: this.changePassword();
case 5: this.validate();
case 6: this.receiveMail(0);
case 7: this.deleteMail(0);
case 8: this.deleteAllMails(0);
case 9: System.exit(0);
}
}
public void display()
{
//System.out.println(" Input your password:"+ password);
System.out.println(" The address are :"+ address + "\n");
//System.out.println(" The password are :"+ password);
//System.out.println("The validateUser is"+ validateUser());
}
}
the emailMain account as follows
import java.io.*;
public class EmailAccountMain
{
public static void main(String[] args)throws IOException
{
EmailAccount e = new EmailAccount();
e.login();
e.address();
e.setInputPassword();
e.ValidateUser();
e.tryAgain();
e.changePassword();
e.receiveMail(0);
e.deleteMail(0);
e.deleteAllMails(0);
//e.display();
}
}
anybody can help me pls.