Can some one please help me figure out my errors in the Program.Java. there are two separate files which i separated with a comment. I am having trouble trying to get my methods to work. The point is for a user to input a password. if the old password is the same as changeit then old password can become newpassword. Please help!!
//my Main.Java File
package Main;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//initialize the scanner, old password and new password//
Scanner passwordScanner = new Scanner(System.in);
String oldPassword;
String newPassword;
//initializing password object//
Password passwordObject = new Password();
//ask user for old password and new password//
System.out.println("Please enter your old password: ");
oldPassword = passwordScanner.nextLine();
System.out.println("Please enter your new password: ");
newPassword = passwordScanner.nextLine();
//Call the methods//
passwordObject.checkPassword(oldPassword);
passwordObject.changePassword(oldPassword, newPassword);
}
}
//-----------------------------------------------------------------------//
//my Password.java file
package Main;
public class Password {
//intialize password to change it//
String password = "changeit";
String somePassword;
boolean succefulChange;
//Check password method//
public boolean checkPassword(String somePassword);
//return true is some password is same as old password, if not then return false//
if (somePassword.equals(oldPassword))
return true;
else
return false;
//Change password method//
public void changePassword(String oldPassword, String newPassword);
//Change old password to new password if old password is true//
if (oldPassword.equals(password))
oldPassword.setText(newPassword);
}
Program.Java.