1 Replies - 263 Views - Last Post: 15 April 2012 - 05:47 PM Rate Topic: -----

#1 rynearson92  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 13-April 12

Driver Tasks -- Password Encryptor

Posted 15 April 2012 - 04:22 PM

Overall i'm having a very difficult time getting the driver to work with the directions handed to me. I'now the rules state not put copy/past your project on here, but this question has been really getting to me. So heres my code

public abstract class Password	{
	private String password;
	private final static String ENCRYPTION_METHOD;

	static	{
	ENCRYPTION_METHOD = "CLEAR TEXT";
		}

	public Password(String password)	{
		this.password = password;

	}

	public String getPassword()	{
		return password;
	}

	public boolean matches (String aString)	{
		if (aString.equals(password))	{
			return true;	}

			else	{
				return false;	}
			}

	public String toString()	{
		return password;
	}

	public static String getEncryptionMethod()	{
		return ENCRYPTION_METHOD;
	}

	abstract String decrypt();

	}


public class EncryptedPassword extends Password	{
	private final static String ENCRYPTION_METHOD;

	static	{
	ENCRYPTION_METHOD = "PERMUTATION";
		}

	public EncryptedPassword(String password)	{
		 super(password);
	}


	public boolean matches (String aString)	{
		if	(aString.equals("True"))	{
				return true;	}

				else	{
				return false;	}
					}

	public String toString()	{
		return "Password: " + super.toString();
	}

	public String setPassword()	{
		return getPassword();
	}

	public String decrypt() {
		return getPassword();
	}

	public static String getEncryptionMethod()	{
		return ENCRYPTION_METHOD;
	}
}


public class UserNamePassword extends EncryptedPassword {

	private String userName;

	public UserNamePassword(String password, String userName)	{
		super(password);

	}

	public String getUserName() {
		return userName;
	}

	public boolean matches(String aString) {
		return false;
	}

	public boolean matches(String userName, String password) {
		if (userName.equals(password)) {
			return true;
		}

		else {
			return false;	}
		}


	public String toString() {
		return "User Name: " + userName + "Password: " + super.toString();
	}
}



 import csci130.*;
import java.lang.String.*;

public class Driver	{
	public static void main(String args[]){

	System.out.println("Enter a user name: ");
			String userName = KeyboardReader.readLine();

	System.out.println("Enter a password: ");
			String password = KeyboardReader.readLine();

 Password pass = new EncryptedPassword("s0cci31");

System.out.println("Password reference pointing to an EncryptedPassword object");
System.out.println("-----------------------------------------------------------------------------");

System.out.println("Encrypted Password: " + pass.getPassword());
System.out.println(pass.getEncryptionMethod());
System.out.println(pass.toString());
System.out.println("Password is: " + password);

		}
	}



Overall I've allowed the user to input a user name and password

I want to Use the password to instantiate a new Password reference, which points to a EncryptedPassword object, but i'm not sure if i did that right.
I don't think i called the getPassword, getEncryptionMethod, and toString methods of the newly instantiated object, and printed the information to the screen correctly.
And i have no idea how to tell the user to re-enter the password and be able to tell them whether or not they entered it correctly... I could use some help, this has been very stressful..

Is This A Good Question/Topic? 0
  • +

Replies To: Driver Tasks -- Password Encryptor

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8316
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: Driver Tasks -- Password Encryptor

Posted 15 April 2012 - 05:47 PM


Duplicated post
You are wasting our times

This post has been edited by pbl: 15 April 2012 - 05:48 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1