Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a new class called ForbiddenWords. ForbiddenWords contains two instance variables, an ArrayList of String, and a Scanner. ForbiddenWords contains a single constructor which accepts

Create a new class called ForbiddenWords. ForbiddenWords contains two instance

variables, an ArrayList of String, and a Scanner.

ForbiddenWords contains a single constructor which accepts a single String as a

parameter. The String is the name of the file that contains the list of forbidden words. The constructor should:

i. Instantiate the ArrayList of String ii. Instantiate the Scanner. Instead of reading from System.in, we want to read

from a new File whose name is the String passed to the constructor. Your constructor should contain a line of code that looks like this:fileScanner = new Scanner(new File(fileName));

iii. Use a while loop and the Scanners hasNext method to loop through the list of words and add each one to the ArrayList of String.

Forbidden words contains a single public method called containsWord. It accepts a String, and returns true if the String is in the list of forbidden words, else it returns false.

10. Modify PasswordValidator so that it has a ForbiddenWords instance variable. Initialize the ForbiddenWords object inside the PasswordValidator start method. Pass in the name of your word list. For example, mine looks like this:

wordlist = new ForbiddenWords("src/ca/bcit/comp1510/lab9/words.txt");11. Modify your PasswordValidators event handler so that it uses the ForbiddenWords

object to ensure the potential password does not contain any of the forbidden Strings.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions