CMSC204 Assignment 1 to 6 solutions

$140.00

Original Work ?
Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

CMSC204 Assignment 1 Passwords

Concepts tested by this program:

ArrayList

static

Read  Files

Javadoc

JUnit Tests

Exceptions

 

Create an application that will check for valid passwords.  The following rules must be followed to create a valid password.

 

  1. At least 6 characters long
  2. 10 or more characters is a strong password, between 6 and 9 characters is a weak (but acceptable) password.
  3. At least 1 numeric character
  4. At least 1 uppercase alphabetic character
  5. At least 1 lowercase alphabetic character
  6. At least 1 special character
  7. No more than 2 of the same character in a sequence

Hello@123 – OK

AAAbb@123 – not OK

Aaabb@123 – OK

 

Operation:

When the application begins, the user will be presented with a screen that states the above instructions for creating a password, two text entry boxes for typing in a password, and three buttons.

If the user wants to check a single password, they will type in the password in both boxes and select the “Check Password” button.

If the user wants to read in and check a list of passwords, they will select the “Check Passwords in File” button, be presented with a file explorer, and select the file to read from.  Those passwords that failed the check will be displayed, with their error message.

Specifications:

 

The Data Element

String

The Data Structure

ArrayList of Strings

Utility Class

  1. Create a PasswordCheckerUtility class based on the Javadoc given you.
  2. The PasswordCheckerUtility class will have at least three public methods:
  • isValidPassword:

This method will check the validity of one password and return true if the password is valid and throw one or more exceptions if invalid.

  • isWeakPassword:

This method will che  throw an exception.

  • getInvalidPasswords

This method will check an ArrayList of passwords and return an ArrayList with the status of any invalid passwords (weak passwords are not considered invalid).  The ArrayList of invalid passwords will be of the following format:

<password><blank><message of exception thrown>

  • For each password requirement, you must have a static private method that validates the password for that requirement and throws an exception if invalid.
  1. Create a separate exception classes for each exception listed in PasswordCheckerUtility Javadoc.

Hints:

  • Always check for the length of the password first, since that is the easiest and fastest check. Once the password fails one rule, you do not need to check the rest of the rules.
  • To check for a special symbol, use the “regular expression” construct. Check the whole password, not just an individual character, using the following:

Pattern pattern = Pattern.compile(“[a-zA-Z0-9]*”);

Matcher matcher = pattern.matcher(str);

return (!matcher.matches());

 

The GUI:

The GUI has been provided, however you need to:

  • Ask the user to enter the password and to re-type the password. If the two are not the same, inform the user.
  • Use methods of PasswordCheckerUtility to check validity of one password when user clicks on “Check Password” button.
  • Use methods of PasswordCheckerUtility to check validity of a file of passwords when user clicks on “Check Passwords in File” button.
  • Use a FileChooser for the user to select the input file.
  • Use try/catch structure to catch exceptions thrown by PasswordCheckerUtility methods

 

Exceptions

Provide exception classes for the following:

  1. Length of password is less than 6 characters (class LengthException)

Message – The password must be at least 6 characters long

  1. Password doesn’t contain an uppercase alpha character (class NoUpperAlphaException)

Message – The password must contain at least one uppercase alphabetic character

  1. Password doesn’t contain a lowercase alpha character (class NoLowerAlphaException)

Message – The password must contain at least one lowercase alphabetic character

  1. Password doesn’t contain a numeric character (class NoDigitException)

Message – The password must contain at least one digit

  1. Password doesn’t contain a special character (class NoSpecialCharacterException)

Message – The password must contain at least one special character

  1. Password contains more than 2 of the same character in sequence (class InvalidSequenceException)

Message – The password cannot contain more than two of the same character in sequence.

  1. Password contains 6 to 9 characters which are otherwise valid (class WeakPasswordException)

Message – The password is OK but weak – it contains fewer than 10 characters.

  1. For GUI – check if Password and re-typed Password are identical (class UnmatchedException)

Message – The passwords do not match

Throw this exception from the GUI, not the utility class.

 

Note: If more than one error is present in a password, use the above order to throw exceptions.  For example, if a password is “xxyyzzwwaa$”, it fails rules 2 and 4 above.  Throw a NoUpperAlphaException, not a NoDigitException.

 

Junit methods:

  • setup
  • teardown
  • for each password requirement method in the PasswordCheckerUtitily you must have a test case that passes and another one that fails
  • success and fail test cases for each public method in the PasswordCheckerUtitily
  • The file that you use for getInvalidPasswords method Junit test must contain at least one invalid and one valid of each password requirement case.

 

This is a sample of Junit test cases that you must have:

 

 

If you select the button which reads “Check Passwords in File”, you will be presented with a file chooser.  You must navigate to where you stored the file “passwords.txt” and load it.  The file will be in the following format (one password per line):

 

 

 

Examples:

 

 

  1. No lowercase alphabetic character

 

 

 

 

Displayed to user:

 

 

 

  1. No digit

 

 

 

 

Displayed to user:

 

 

 

 

 

  1. If the password is OK, but between 6 and 10 characters, you will see:

 

  1. If password has more than two of the same characters in a row

 

Displayed to user:

 

 

 

 

 

  1. If password is valid

 

 

 

 

 

 

 

  1. If the passwords do not match:

 

 

 

Displayed to user:

 

 

 

  1. Based on the file above, when the user selects “Check Passwords in File”:

 

Displays errors to user when selecting Check Passwords in File. Note that valid passwords (including weak but otherwise valid passwords) are NOT displayed.

 

 

 

 

 

 

Deliverables:

 

Design:

Initial design document (UML and/or pseudo-code)

 

Implementation:

Final design document

Java files – The src folder with your driver (javafx application), data manager, exceptions and Junit Test (.java) files

Javadoc files – The entire doc folder with your javadoc for student generated files

Learning Experience document

GitHub screen shot

 

Deliverable format: The above deliverables will be packaged as follows. Two compressed files in the following formats:

LastNameFirstName_AssignmentX.zip [compressed file containing following]:

doc [a directory] include the entire doc folder with the javadoc for

student generated files

file1.html (example)

file2.html (example)

class-use (example directory)

LearningExperience.doc or other text format

src [a directory] contains your driver (javafx application), data manager, exceptions and Junit Test (.java) files

File1.java (example)

File2.java (example)

File_Test.java (example)

GitHub screen shot.

LastNameFirstName_AssignmentX_Moss.zip [compressed file containing only]:

.java file which includes the driver (javafx application), data manager, exceptions and Junit Test (.java) files – NO

FOLDERS!!

File1.java (example)

File2.java (example)

 

 

 

 

 

 

 

 

 

Grading Rubric

CMSC 204 Project 1

Overview:

There are two parts to the rubric.   First, the project is graded on whether it passes public and private tests.  If it does not compile, a 0 will be given. These points add up to 100.  Second, the score is decremented if various requirements are not met, e.g., missing required methods, missing Junit test cases, no Javadoc, no UML diagram, uses constructs that are not allowed, etc.

 

TESTING        (100 pts)                                                    

Compiles                                                                                                       35 pts _____

Student Junit required student tests                                                              8 pts _____

 

Passes JUnit student tests                                                                             7 pts _____

Passes public JUnit tests                                                                                  15 pts _____

Passes private instructor tests                                                                       15 pts _____

Execution: runs without errors (either run-time or logic errors                   20 pts _____

Possible Sub-total                                                                               100 pts _____

 

 

REQUIREMENTS  (Subtracts from Testing total)

 

Documentation:

Javadoc for student generated files not submitted (entire doc folder)        -5 pts _____

Documentation within source code was missing or incorrect                   -1.5 pts _____

Description of what class does was missing

Author’s Name, @author, was missing

Methods not commented properly using Javadoc @param, @return

JUnit STUDENT methods were not implemented                                       -10 pts _____

Screen shot of GitHub repo with Assignment1 files was not submitted     -5 pts _____

MOSS files were not submitted                                                                       -5 pts _____

Learning Experience                                                                               -2.5 pts _____

In 3+ paragraphs, highlight your lessons learned and learning experience from working on this project.  What have you learned? What did you struggle with? What would you do differently on your next project?

 

Programming Style:

Incorrect use of indentation, statements, structures                                    -2 pts _____

 

Design:

Implementation does not follow final design                                                      -4 pts _____

 

Classes do not have the functionality specified, i.e.,

  1. PasswordCheckerUtility class                                                     -10 pts _____

does not have a method to check validity of password

does not have a method to check validity of  ArrayList of passwords

does not follow the Javadoc provided

does not have private method for each password requirement

  1. GUI does not compile         -5 pts _____
  2. Exceptions classes                                                                    -10 pts _____

does not have exception class for each invalid password rule

does not have exception class for weak password

does not have exception class if password and re-type password don’t match

does not have exception class for each password requirement

Possible decrements:                                                                          -60 pts _____

Possible total grade:                                                                             100 pts _____

 

CMSC 204 Assignment 2 Notation

Infix notation is the notation commonly used in arithmetical and logical formulae and statements. It is characterized by the placement of operators between operands – “infixed operators” – such as the plus sign in “2 + 2”.

Postfix notation is a notation for writing arithmetic expressions in which the operands appear before their operators. There are no precedence rules to learn, and parentheses are never needed.

You will be creating a utility class that converts an infix expression to a postfix expression, a postfix expression to an infix expression and evaluates a postfix expression.

The GUI is provided.

 

 Concepts tested:

Generic Queue

Generic Stack

Exception handling

 

Data Element

      String

 

Data Structures

  1. Create a generic queue class called NotationQueue. NotationQueue will implement the QueueInterface given you. You will be creating NotationQueue from scratch (do not use an internal object of the Queue class from java.util)
  2. Create a generic stack class called NotationStack. NotationStack will implement the Stack Interface given you. You will be creating NotationStack from scratch (do not use an internal object of the Stack class from java.util)

 

Utility Class
The Notation class will have a method infixToPostfix to convert infix notation to postfix notation that will take in a string and return a string, a method postfixToInfix to convert postfix notation to infix notation that will take in a string and return a string, and a method to evaluatePostfix to evaluate the postfix expression. It will take in a string and return a double.

      In the infixToPostfix method, you MUST use a queue for the internal structure that holds the postfix solution. Then use the toString method of the Queue to return the solution as a string.

For simplicity sake:

  1. operands will be single digit numbers
  2. the following arithmetic operations will be allowed in an expression:

+          addition

–           subtraction

*          multiplication

/           division

Exception Classes

Provide the following exception classes:

  1. InvalidNotationFormatException – occurs when a Notation format is incorrect
  2. StackOverflowException – occurs when a top or pop method is called on an empty stack.
  3. StackUnderflowException – occurs when a push method is called on a full stack.
  4. QueueOverflowException – occurs when a dequeue method is called on an empty queue.
  5. QueueUnderflowException – occurs when a enqueue method is called on a full queue.

 

GUI Driver (provided)

 

  1. Initially neither radio button for notation is selected. When a radio button is selected, the Convert button is enabled and the appropriate label and field are visible for the user input.
  2. When the user selects the Convert button, the appropriate label and field with the conversion will be displayed.
  3. When the user selects the Evaluate button, the “answer” to the expression will be displayed.
  4. When the Exit button is selected, the application will close.

 

 

ALGORITHMS

 

Infix expression to postfix expression:

 

Read the infix expression from left to right and do the following:

 

If the current character in the infix is a space, ignore it.

If the current character in the infix is a digit, copy it to the postfix solution queue

If the current character in the infix is a left parenthesis, push it onto the stack

If the current character in the infix is an operator,

  1. Pop operators (if there are any) at the top of the stack while they have

equal or higher precedence than the current operator, and insert the                                 popped operators in postfix solution queue

  1. Push the current character in the infix onto the stack

If the current character in the infix is a right parenthesis

  1. Pop operators from the top of the stack and insert them in postfix solution queue until a left parenthesis is at the top of the stack, if no left parenthesis-throw an error
  2. Pop (and discard) the left parenthesis from the stack

When the infix expression has been read, Pop any remaining operators and insert them in postfix solution queue.

 

 

Postfix expression to infix expression:

 

Read the postfix expression from left to right and to the following:

 

If the current character in the postfix is a space, ignore it.

If the current character is an operand, push it on the stack

If the current character is an operator,

  1. Pop the top 2 values from the stack. If there are fewer than 2 values throw an error
  2. Create a string with 1st value and then the operator and then the 2nd
  3. Encapsulate the resulting string within parenthesis
  4. Push the resulting string back to the stack

When the postfix expression has been read:

If there is only one value in the stack – it is the infix string, if more than one

value, throw an error

 

Evaluating a postfix expression

 

Read the postfix expression from left to right and to the following:

 

If the current character in the postfix expression is a space, ignore it.

If the current character is an operand or left parenthesis, push on the stack

If the current character is an operator,

  1. Pop the top 2 values from the stack. If there are fewer than 2 values throw an error
  2. Perform the arithmetic calculation of the operator with the first popped value as the right operand and the second popped value as the left operand
  3. Push the resulting value onto the stack

When the postfix expression has been read:

If there is only one value in the stack – it is the result of the postfix expression, if

more than one value, throw an error

 

 

 

 

Examples:

 

At startup

            

 

 

 

After selecting Infix to Postfix                                                    After selecting Postfix to Infix

 

 

 

After selecting Convert Button

 

 

 

 

After selecting Evaluate button

 

 

Grading Rubric – CMSC 204 Project #2

 

Name _____________________________    .

 

PROGRAMMING    (100 pts)                                                                                     

Compiles                                                                                                    40 pts _____

Accuracy

Passes public JUnit tests                                                                       15 pts _____

Passes STUDENT JUnit tests                                                               10 pts _____

Passes private instructor tests                                                               15 pts _____

Execution: runs without errors (either run-time or logic errors)               20 pts _____

Possible Sub-total                                                                               100 pts _____

REQUIREMENTS  (Subtracts from Programming total)

Documentation:

Javadoc was not provided for all student generated classes                        – 5 pts _____

Documentation within source code was missing or incorrect                     – 5 pts _____

Description of what class does was missing

Author’s Name, @author, was missing

Methods not commented properly using Javadoc @param, @return

JUnit STUDENT methods were not implemented                                         -5 pts _____

Learning Experience (text document)                                                             -4 pts _____

In 3+ paragraphs, highlight your lessons learned and learning experience from working on this project.  What have you learned? What did you struggle with? What would you do differently on your next project?

 

Programming Style:

Incorrect use of indentation, statements, structures                                    -10 pts _____

 

Design:  Classes do not have the functionality specified, i.e.,

  1. Data Structures classes                                                            – 16 pts_____
  • Generic Stack class
  • Generic Queue class
  1. Utility class – Notation                                                             -15 pts_____
  • Does not follow provided Javadoc
  • Does not correctly handle exceptions

Possible decrements:                                                                          -60 pts _____

Possible total grade:                                                                           100 pts _____

CMSC204 Assignment 3 Double Linked Lists

Your assignment is to write a generic double singly-linked list class with an iterator, and a generic sorted double singly-linked list class with an iterator that inherits from your generic double singly-linked list class. The GUI has been provided for you for this assignment to help you visualize your linked list. Your list classes will also be tested with Junit tests. Upload the initial files from Blackboard and your working files in a directory into the repository in GitHub you created in Lab 1 and take a screen shot of the files.

Concepts tested by this assignment

 

 

 

 

 

Exception handling

Generic Classes

Double Linked List

Ordered Double Linked List

Iterators

Comparators

Classes

 

 

 

 

 

 

BasicDoubleLinkedList

 

This generic double singly-linked list relies on a head (reference to first element of the list) and tail (reference to the last element of the list). Both the head and the tail are set to null when the list is empty. Both point to the same element when there is only one element in the list, and now the element’s “next” and “previous” references point to null. A node structure has only two fields: data and the next references. The class must only define the following entities: an inner class Node, an inner class that implements ListIterator (for the iterator method), head and tail references and an integer representing the list size. However only the next(), hasNext(), previous() and hasPrevious() methods of the ListIterator are you required to implement.  The rest of the methods can throw the UnsupportedOperationException, such as:

public void remove() throws UnsupportedOperationException{

throw new UnsupportedOperationException();}

All the entities are defined as protected so they can be accessed by the subclass.  Follow the Javadoc that is provided.

 

SortedDoubleLinkedList

A generic sorted double linked list will be constructed using a provided Comparator to determine how the list is to be sorted.  It extends BasicDoubleLinkedList class.  The addToFront and the addToEnd methods will not be supported and an add method will be added that inserts to the double linked list in sorted order dependent on the Comparator. Follow the Javadoc that is provided.

 

Exception Handling

  • UnsupportedOperationException – this exception is a Java library exception and will be returned by the addtoFront and addToEnd implementations of the SortedDoubleLinkedList class and by the remove method of the iterator.
  • NoSuchElementException – this exception is a Java library exception and will be returned by the next function within the iterator class when there are no more elements in the linked list.

 

GUI driver (provided for you)

          A GUI driver has been provided for you to help you visualize your doubly-linked lists. Here is the minimum that must be in place to start using the GUI driver effectively.

  • All methods in your BasicDoubleLinkedList and SortedDoubleLinkedList must be stubbed.
  • The addToFront or addToEnd method of the BasicDoubleLinkedList must be implemented to create a basic double singly-linked list.
  • The add method of the SortedDoubleLinkedList must be implemented to create a sorted double singly-linked list.
  • The toArrayList method in both the BasicDoubleLinkedList and SortedDoubleLinkedList, which returns an arraylist of the items in the list from the head of list to the tail of list. This method is used to display the contents of the lists.

 

Testing

  1. Your code should cause the BasicDoubleLinkedList_Test tests to succeed.
  2. Your code should cause the SortedDoubleLinkedList_Test tests to succeed.
  3. Create a JUnit Test – Basic
  4. Create a JUnit Test – SortedDoubleLinkedList_STUDENT_Test.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Examples using GUI driver

 

 

Adding to a Basic List                                                                                                    Adding to a Sorted List

 

 

 

 

Removing Second from basic                                                                                                     Removing Thomas from sorted

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Start the iterators for Basic and Sorted. Think of iterators being “in between” nodes.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Example of selecting “Next” for Basic and then for Sorted list. Think of iterators being “in between” nodes.

 

 

Example of “Next” for basic and “Previous” for Sorted. Think of iterators being “in between” nodes.

Deliverables

 

 

 

Deliverables / Submissions:

Design: UML class diagram with algorithm (pseudo-code) for methods

Implementation: Submit a compressed file containing the follow (see below):  The Java application (it must compile and run correctly); Javadoc files in a directory; a write-up as specified below.  Be sure to review the provided project rubric to understand project expectations.  The write-up will include:

  • Final design: UML diagram with pseudo-code
  • In three or more paragraphs, highlights of your learning experience

 

Deliverable format: The above deliverables will be packaged as follows. Two compressed files in the following formats:

  • zip, a compressed file in the zip format, with the following:
    • Write up (Word document) – reflection paragraphs
    • UML Diagram – latest version (Word or jpg document)
    • doc (directory) – Javadoc
        • File1.html (example)
        • File2.html (example)
        • Sub-directory (example)
  • src (directory)
        • File1.java (example)
        • File2.java (example)

 

  • zip, a compressed file containing one or more Java files:
    • java (example)
    • java (example)

This folder should contain Java source files only

CMSC204 Assignment 4 database of courses

Most data is stored in databases, for ready access and organization.  Our course data is backed up by IT in databases which makes our data easy to access and use.

 

Write a program that creates a database of courses.  It will either read from a file of courses, or allow the user to add one course at a time.   Upload the initial files and your working files in the repository in GitHub you created in Lab 1, in a directory named Assignment4. Take a screenshot of your repo, and post the assignment to the Assignment 4 dropbox.

 

Concepts tested by this assignment

 

 

Hash Table,

Link List,

hash code, buckets/chaining,

exception handling,

Classes

read/write files using FileChooser

 

Data Element – CourseDBElement,

CourseDBElement implements Comparable, and consists of five attributes: the Course ID (a String), the CRN (an int), the number of credits (an int), the room number (a String), and the instructor name (a String).   Normally the CourseDBElement will be an object consisting of these five attributes, and is referred to as a CDE.

 

Data Structure – CourseDBStructure

Implements the CourseDBStructureInterface that is provided.

You will be implementing a hash table with buckets.  It will be an array of linked lists of CourseDBElements.  Each CDE will have a hash code that comes from the CRN, since the CRN is unique for courses.  Note that the CRN is an int, and the tests require the hashcode of a string, so you will need to coerce it to a String, and take the hash code of the resulting string.  The add method will take a CourseDBElement and add it to the data structure. If a linked list at the relevant hash code doesn’t exist, create a LinkedList with the first element being the CDE and add it to the HashTable. If the LinkedList already exists, add the CDE to the existing list. Two constructors for the CDS will be required, one that takes in an integer that is the estimated number of courses, the other is used for testing purposes.  The comments in the CourseDBStructureInterface (provided) should help you figure out how to set the length of the hash table.  You will not need to use the 4k+3 code.

 

Data Manager – CourseDBManager

Implements the CourseDBManagerInterface that is provided.

The data manager allows the user to read the courses from a file or to enter the data by hand, and uses an Alert to print out the database elements. The input is read from a file or read from the textfields and is added to the data structure through the add method.  The add method uses the CDS add method. The CourseDBManager is also referred to as a CDM.

 

Exception Classes

IOException – created and thrown when user selects an input file that cannot be read or attempting to retrieve a CDE that does not exist in the DB.

 

GUI Driver (provided)

  • User will only create a course database once they have entered an input file or entered one or more sets of attributes.
  • Buttons and textfields are grayed out if they are not relevant at the current time.
  • A FileChooser is used to select the input and output files.
  • Inform the user if there is an error with the input file.
  • Use exception handling for the validity of the files.
  • A way is provided for the user to “clear” the text fields.
  • A way is provided for the user to select a CRN and retrieve the corresponding course.

 

Testing

Create a JUnit Test – CourseDBManager_STUDENT_Test.

 

Assignment Details

 

 

 

 

 

There will be two ways to create a course database.  The first requires a document to be read from an input file.  The second reads the input from five textfields.  Once there is data in the database, the GetCourse button will be enabled to allow you to see the data. See the example below.

 

 

 

 

 

 

Examples

 

 

 

 

Example of creating a Course database from an input file

 

 

 

 

 

Select the input file button and navigate to the file.

 

 

 

Use ShowDB button to display the CDEs that were read:

 

 

 

Example of Creating a CDE from text fields.  First select the other radio button, then fill in the textfields, then select the “Add to DB” button.

 

Select the Show DB button to see the resulting CDEs.

 

 

Example of retrieving a CDE.  First select the GetCourse button.  Three components at the bottom of the screen will become enabled.  Then fill in the CRN and select the FindCourse button to find the applicable course from the database.

 

 

The general design is shown here to guide you in formulating your own design:

 

 

 

 

Deliverables

 

 

Deliverables / Submissions:

Design: UML class diagram with algorithm (pseudo-code) for methods

Implementation: Submit a compressed file containing the follow (see below):  The Java application (it must compile and run correctly); Javadoc files in a directory; a write-up as specified below.  Be sure to review the provided project rubric to understand project expectations.  The write-up will include:

  • UML diagram
  • In three or more paragraphs, highlights of your learning experience

 

Deliverable format: The above deliverables will be packaged as follows. Two compressed files in the following formats:

  • zip, a compressed file in the zip format, with the following:
    • Write up (Word document) – reflection paragraphs
    • GitHub repository with java files from Assignment 4.
    • Final Design: UML Diagram – latest version (Word or image)
    • doc (directory) – Javadoc
        • subdirectories (as is)
        • File1.html (example)
        • File2.html (example)
  • src (directory)
        • File1.java (example)
        • File2.java (example)

 

  • zip, a compressed file containing one or more Java files:
    • java (example)
    • java (example)

This folder should contain Java source files only

 

 

CMSC204 Assignment 5 Morse Code Converter

Samuel F. B. Morse produced the first working telegraph set in 1836. This made transmission possible over any distance. The first Morse Code message, “What hath God wrought?”, was sent from Washington to Baltimore.

Morse code was extensively used for early radio communication beginning in the 1890s.

In the early part of the twentieth century, the majority of high-speed international communication was conducted in Morse code, using telegraph lines, undersea cables, and radio circuits.

 

Morse code can also be transmitted using light which sometimes happens between ships at sea. It is used in emergencies to transmit distress signals when no other form of communication is available. The standard international distress signal is •••—••• (SOS).

 

Write the classes required to create a Morse Code Converter Utility. Your Morse Code Converter Utility will be using a generic linked binary tree with generic TreeNodes to convert Morse Code into English. There is no GUI requirement for this assignment. You are supplied a GUI for testing purposes.

 

 

 

Generic Classes

Utility Class (all static methods)

Linked Trees

Classes

Building a Tree for conversion purposes

 

 

 

 

Data Element – TreeNode class

This generic class is used in the MorseCodeTree classes.  The class consists of a reference to the data and a reference to the left and right child.  Follow the Javadoc that is provided.  The Javadoc only lists those public methods that are required to pass the Junit tests.  You may add any private methods you need for your design.

 

Data Structure – MorseCodeTree class

A generic linked binary tree which inherits from the LinkedConverterTreeInterface.  The class uses an external generic TreeNode class parameterized as a String: TreeNode<String>.  This class uses the private member of root.  Nodes are added based on their morse code value.  A ‘.’ (dot) means to traverse left and a ‘-‘ (dash) means to traverse right. The constructor will call the method to “build the tree”.  Follow the Javadoc that is provided. The Javadoc only lists those public methods that are required to pass the Junit tests.  You may add any private methods you need for your design.

Utility class – MorseCodeConverter

The MorseCodeConverter contains a static MorseCodeTree object and constructs (calls the constructor for) the MorseCodeTree.

This class has two static methods convertToEnglish to convert from morse code to English. One method is passed a string object (“.-.. — …- . / .-.. — — -.- …”).  The other method is passed a file to be converted.  These static methods use the MorseCodeTree to convert from morse code to English characters.  Each method returns a string object of English characters.

There is also a static printTree method that is used for testing purposes – to make sure the tree for MorseCodeTree was built properly.

Use the Javadoc provided to make sure that your MorseCodeConverter class follows the method headers so that the MorseCodeConverterTest will run correctly.

Testing – JUnit Test Classes

You must add at least 1 test for MorseCodeConverter.convertToEnglish(String) and at least 1 test for MorseCodeConverter.convertToEnglish(File) to the MorseCodeConverterTest class.  You must create a JUnit test for your MorseCodeTree class. Include your test files with your code files.

 

 

 

 

 

This is a table for the conversion from Morse Code to alpha letters.

Building the MorseCodeTree (method buildTree)

Your MorseCodeTree is a 4 levels tree.  Insert a mapping for every letter of the alphabet into the tree map.  The root is a TreeNode with an empty string.  The left node at level 1 stores letter ‘e’ (code ‘.’) and the right node stores letter ‘t’ (code ‘-‘).  The 4 nodes at level 2 are ‘i’, ‘a’, ‘n’, ‘m’ (code ‘..’, ‘.-‘, ‘-.’, ‘—‘).  Insert into the tree by tree level from left to right.  A ‘.’ will take the branch to the left and a ‘-‘ will take the branch to the right.  This is the structure of the tree.

Using the MorseCodeTree

Use the MorseCodeTree to convert Morse Code to English by taking the code and finding it’s corresponding English letter by traversing the MorseCodeTree, ‘.’ branches to the left and ‘-‘ branches to the right.  The code ‘.–.’ would branch to the left, then to the right, then to the right, then to the left to Fetch the letter ‘p’.  Each letter is delimited by a space (‘ ‘).  Each word is delimited by a ‘/’.

 

Some suggestions:

  1. There is a morse code translator at:

https://morsecode.scphillips.com/jtranslator.html

 

This will help you build files and test cases for your JUnit Tests.

 

 

 

 

 

 

Test Cases:

Hello World

 

 

How do I love thee let me count the ways

 

 

 

Njs célébrer

 

 

 

Deliverables / Submissions:

Design: UML class diagram with algorithm (pseudo-code) for methods

Implementation: Submit a compressed file containing the follow (see below):  The Java application (it must compile and run correctly); Javadoc files in a directory; a write-up as specified below.  Be sure to review the provided project rubric to understand project expectations.  The write-up will include:

  • UML diagram
  • In three or more paragraphs, highlights of your learning experience

 

Deliverable format: The above deliverables will be packaged as follows. Two compressed files in the following formats:

  • zip, a compressed file in the zip format, with the following:
    • Write up (Word document) – reflection paragraphs
    • UML Diagram – latest version (Word or jpg document)
    • doc (directory) – Javadoc
        • File1.html (example)
        • File2.html (example)
  • src (directory)
        • File1.java (example)
        • File2.java (example)

 

  • zip, a compressed file containing one or more Java files:
    • java (example)
    • java (example)

This folder should contain Java source files only

 

CMSC204 Assignment 6

Behind every Google Map, there is a much more complex structure that’s the key to your queries but hidden from your view. It contains the logic of places: their no-left-turns and freeway on-ramps, speed limits and traffic conditions. This is the data that you’re drawing from when you ask Google to navigate you from point A to point B.

 

In this project you will be creating an application to maintain a network of towns and the roads connecting them. The application will use Dijkstra’s Shortest Path algorithm to find the shortest distance between any two towns. Upload the initial files and your working files to the repository in GitHub you created in Lab 1, in a directory named Assignment6.

Concepts tested by this assignment

 

 

 

 

 

Implement Graph Interface

Use Graph to maintain a network of Vertices

Implement Shortest Path Algorithm

Classes

 

 

 

 

 

Data Element – Town (Vertex)

Create a Town class that holds the name of the town and a list of adjacent towns, and other fields as desired, and the traditional methods (constructors, getters/setters, toString, etc.).  It will implement the Comparable interface.  This is the class header:

public class Town implements Comparable<Town>

Two towns will be considered the same if their name is the same.

Data Element – Road (Edge)

Create a class Road that can represent the edges of a Graph of Towns.  The class must implement Comparable.  The class stores references to the two vertices(Town endpoints), the distance between vertices, and a name, and the traditional methods (constructors, getters/setters, toString, etc.), and a compareTo, which compares two Road objects. Since this is a undirected graph, an edge from A to B is equal to an edge from B to A. This is the class header:

public class Road implements Comparable<Road>

 

Data Structure – Graph, implements GraphInterface

Create a Graph class that implements the GraphInterface given you.  For Graph<V,E>,  V is the vertex type (a Town), E is the edge type (a Road).  You will need to decide how to store the graph, use an adjacent matrix or an adjacency list.  This is the class header:

public class Graph implements GraphInterface<Town, Road>

Within the Graph interface is a method shortestPath, which finds the shortest path from a given source Town to a destination Town. Since there is a unique shortest path from every vertex to the source, there is a back-pointer to the previous vertex.  The method shortestPath calls dijkstraShortestPath which finds the shortest path from the source to every other vertex in the graph.  You will be coding the Dijkstra’s Shortest Path algorithm.  You will then be able to find the connections between two towns through the roads that connect them.

You may use the adjacency matrix approach found in the text book, or you may use a set of Towns and a set of Roads. The ShortestPath algorithm typically uses a weighted graph which means that the edges have a weight, and this is used to determine the shortest path.  For this implementation, each weight will be the distance of the road in miles.

Data Manager – implements TownGraphManagerInterface

Your TownGraphManager will hold an object of your Graph. Implement the TownGraphManagerInterface. There are methods to populate the graph (reading from a text file), add a town (vertices), add a road (edge), list all towns and all roads, and list towns adjacent to a given town.

Your solution will find the shortest path from a start town to a destination town.  It will account for the possibility of a disjoint graph (i.e., not all vertices can be reached from all other vertices.)

You may add any methods as needed for your design.

Exception Classes

FileNotFoundException – created and thrown when the selected input file is not found.

IOException – created and thrown when user selects an input file that cannot be read (check out the methods of File).

Note that these exceptions exist in the Java API.

GUI Driver (provided for you)

The GUI has four sections: a Town section where you can add towns, a Road section where you add roads, a Find Connection section, and an administration section.  It has a Read File button, which allows the text files provided to be read and populate the graph.

 

Testing

  1. Your completed implementation must pass the TownGraphManagerTest.java and the GraphTest.java.
  2. The tests marked GFA (“Good Faith Attempt”) are the minimal testing that must pass in order for your implementation to meet the good faith attempt.
  3. Create a JUnit Test – TownGraphManager_STUDENT_Test. Test all the methods of the TownGraphManager with a different set of data than the TownGraphManagerTest provided for you.
  4. Create a JUnit Test – Graph_STUDENT_Test. Test all the methods of the Graph with a different set of data than the GraphTest provided for you.
  5. Create a Junit Test – Road_STUDENT_Test. Test all the methods of your Road class.
  6. Create a Junit test – Town_STUDENT_Test. Test all the methods of your Town class.

 

Assignment Details

 

 

 

 

 

Populating the Data Structure

You will be reading from a data file.  You are provided with two sample files: MD Towns.txt and US Towns.txt along with two PowerPoint slides showing these graphs.

 

The Towns.txt files hold the information for the individual Towns and Roads, and is in the following format:

road-name,miles;town-name; town-name

For example:

I-94,282;Chicago;Detroit

Notice that the road-name and miles are separated by a comma, while the road information and the two towns are separated by semi-colons.

 

After reading these files, you will have an initial set of vertices and edges in your Graph.

 

 

Examples

 

 

 

 

 

After reading in the MD Town file                 After reading in the US Town file           

 

 

The GUI (Provided for you)

The GUI will have four sections: an Add Town section, an Add Road section, a Find Connection section, and an administration section.  There will be four ComboBoxes each containing the same list of Towns.  On startup the graph will be empty.

 

Add a Town Button

      The user may add a new Town by typing its name in the textfield.  If the textfield is blank when the Add Town button is selected, the GUI should show an error message.  When a new Town is added, the TownGraphManager will add it to the graph, and the Town’s name will be added to the four ComboBoxes.

Add a Road Button

      To add a road, a town must be selected from each of the two ComboBoxes in the Add Road section, an integer distance entered, and a road name entered.  When the Add Road button is selected, the edge is created and entered in the graph.

 

 

Find Connection Button

Display all the available towns in the ComboBoxes  (in alpha order by name).  When the user selects the towns, display the name in the ComboBoxes.  When the user selects the “Find Connection” button, the TownGraphManager’s shortestPath method is called.  The resulting list of roads connecting towns, and the distance along each road, is displayed in the text area.

If the “source” town and “destination” town are the same, or if there is no route between the two, state that in the text area.

Read File Button

The Towns.txt files hold information for individual Towns and Roads, and is in the following format:

road-name,miles;town-name;town-name

For example:

I-94,282;Chicago;Detroit

Notice that the road-name and miles are separated by a comma, while the road information and the two towns are separated by semi-colons.

 

Exit Button

The program will terminate.

Deliverables

 

 

 

 

Deliverables / Submissions:

Design: UML class diagram with algorithm (pseudo-code) for methods

Implementation: Submit a compressed file containing the follow (see below):  The Java application (it must compile and run correctly); Javadoc files in a directory; a write-up as specified below.  Be sure to review the provided project rubric to understand project expectations.  The write-up will include:

  • UML diagram
  • In three or more paragraphs, highlights of your learning experience

 

Deliverable format: The above deliverables will be packaged as follows. Two compressed files in the following formats:

  • zip, a compressed file in the zip format, with the following:
    • Write up (Word document) – reflection paragraphs
    • Final Design: UML Diagram – latest version (Word or jpg document)
    • Screen shot of GitHub repository with final set of files.
    • doc (directory) – Javadoc
        • File1.html (example)
        • File2.html (example)
  • src (directory)
        • File1.java (example)
        • File2.java (example)

 

  • zip, a compressed file containing one or more Java files:
    • java (example)
    • java (example)

This folder should contain Java source files only