CMSC256 Programming Project 1 to 6 solutions

$140.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

CMSC256 Programming Project 1 – Inheritance Point Value

Learning Objectives:

• Implement multiple Java classes using inheritance and composition using a UML diagram to
guide the program design.
• Demonstrate appropriate documentation of code using class-level and method-level comments.
• Use validation to maintain data integrity at the class level.

The classes needed are shown in the UML class diagram and listed. All classes are required to be in the
same package with the package name cmsc256.
Name, Address and Directory classes are provided. Directory is the driving class for the
program. Do not make any changes in Name and Address classes. If you make any changes to the
Name or Address class, your program will not compile and execute correctly in Gradescope.

You are to implement the following classes:
• Person Class: The class variables and types are shown in the class diagram. Specifically,
RecordNumber is a static variable. It will increase each time you instantiate a new Person
object and will be assigned to the id variable of the currently created instance. Here is the
signature for the constructor of Person class:
public Person(String first, String middle, String last, Address homeAddress,
String phoneNumber, String email)

• Student Class: Student class extends Person class. It has extra variable, level, which
indicates the student level as one of the following, Freshman, Sophomore, Junior, Senior,
Graduate. Constructors of the Student class initialize the level variable in addition to all
variables of super class.
• Employee Class: Employee class extends Person class. It has extra office, salary and
dateHired variables. Constructors of the Employee class initialize all its variables.
• Faculty Class: Faculty class extends Employee class. It has extra variable, rank, which can
either be Adjunct, Instructor, Assistant Professor, Associate Professor, or Professor. Constructors
of the Faculty class initialize all its variables.

• Staff Class: Staff class extends Employee class. It has extra variable which is a String called
title. Constructors of the Staff class initialize all its variables.
You are provided with the driver program called Directory to help guide the development of your
classes. The correct output from executing the Directory program should look like this:
Student:
—————————————
Peter Luong
—————————————
Home Address: 10 FakeHome Street
Staged City, VA 22222
Phone Number: 858-789-8575
Email Address: fake0@ mymail.vcu.edu
ID: 1
Student Level: Freshman
Student:
—————————————
Alice Myers
—————————————
Home Address: 10 FakeHome Street
Staged City, VA 22222
Phone Number: 858-789-8576
Email Address: fake1@ mymail.vcu.edu
ID: 2
Student Level: Senior
Faculty:
—————————————
Maria L Garcia
—————————————
Home Address: 401 West Main Street
Richmond, VA 23284-3019
Phone Number: 804-828-8577
Email Address: fake2@vcu.edu
ID: 3
Office: 323KL
Salary: $60000
Date Hired: 10/10/2010
Rank: Assistant Professor
Faculty:
—————————————
Michael Junior Cook
—————————————
Home Address: 401 West Main Street
Richmond, VA 23284-3019
Phone Number: 804-789-8578
Email Address: fake3@vcu.edu
ID: 4
Office: 356JL
Salary: $50000
Date Hired: 5/5/2015
Rank: Instructor
Staff:
—————————————
Shane Dave
—————————————
Home Address: 20 Staged Home Road
Dummy, VA 33333-1234
Phone Number: 858-789-8579
Email Address: fake4@vcu.edu
ID: 5
Office: 356JL
Salary: $40000
Date Hired: 8/8/2008

Title: Department Secretary
Make sure your classes are well documented – including a comment block header in all source code files
with your name, the course and section numbers, the project name, the program purpose. Be sure to
include appropriate comments throughout your code, choose meaningful identifiers, and use
indentation as shown in your textbook and in class.

Submit your source code files, Person.java, Student.java, Employee.java,
Staff.java, and Faculty.java to the assignment link in Gradescope by midnight on the due
date. You have a maximum of three submission attempts for this project. Additional attempts will not
be allowed, so test your files thoroughly before uploading to Gradescope.

Grading Rubric
Person class:
Instance data members are correctly declared (2 pts.) _________
Default constructor included with appropriate assignment (2 pts.) _________
Parameterized constructor correctly written (5 pts.) _________
Correct use of a static class variable to generate ID numbers (5 pts) _________
getName() method written correctly (1 pts.) _________
toString() method written correctly (5 pts.) _________
Total (20 pts.) _________
Student class:
Instance data member is correctly declared (2 pts.) _________
Default constructor included with appropriate assignment (3 pts.) _________
Parameterized constructor correctly written (5 pts.) _________
toString() method written correctly (5 pts.) _________
Class design includes appropriate code to uphold encapsulation (5 pts.) _________
Total (20 pts.) _________
Employee class:
Instance data member is correctly declared (2 pts.) _________
Default constructor included with appropriate assignment (3 pts.) _________
Parameterized constructor correctly written (5 pts.) _________
toString() method written correctly (5 pts.) _________
Total (15 pts.) _________
Faculty class:
Instance data member is correctly declared (2 pts.) _________
Default constructor included with appropriate assignment (3 pts.) _________
Parameterized constructor correctly written (5 pts.) _________
toString() method written correctly (5 pts.) _________
Class design includes appropriate code to uphold encapsulation (5 pts.) _________
Total (20 pts.) _________
Staff class:
Instance data member is correctly declared (2 pts.) _________
Default constructor included with appropriate assignment (3 pts.) _________
Parameterized constructor correctly written (5 pts.) _________
toString() method written correctly (5 pts.) _________
Total (15 pts.) _________
All classes:
Files named, commented appropriately, and submitted as specified (5 pts.) _________
Java syntax is correct (class names starting with capital letter, variable names
starting with small letter, indentations, correct packages etc) (5 pts.) _________
Project Total (100 pts.) _________

CMSC 256 Programming Assignment 2

Program: RamString implementation of the WackyStringInterface

Points: 100
Develop a Java class called RamString that correctly implements the WackyStringInterface. (The semantics of
the methods in the interface can be determined from their name and from the Javadoc comments in the code.
If not, please ask for clarification on the Discussion Board forum.)

Add two constructors to your RamString
class – one with a single string argument and a second, default, no-arg constructor. The no-argument
constructor should set the instance variable to the string, “Rodney, the Ram” and the value of the string
should never allow to be null.

Important note: This project is focused on character and String manipulation and you are not allowed to use
regular expressions or any classes or methods that make use of regular expressions.
Write a test plan for class RamString using the Test Plan Template document. Specifically, you should create
several different tests for each method of in the interface. Make sure that the tests are not trivial (i.e., have a
specific purpose).

In other words, each test should
1. test a specific piece of functionality and
2. check that the it behaves as expected. In addition, at least two of the tests for method
convertDigitsToRomanNumeralsInSubstring should result in expected exceptions:
MyIndexOutOfBoundsException (provided) in one case, and IllegalArgumentException in the other.

Add a concise comment to each test that you implement to clarify its rationale (e.g., “This test checks whether
the method convertDigitsToWordsInSubstring suitably throws an IllegalArgumentException if startPosition is
greater than endPosition”).

Notes:
• You cannot modify the provided interface, WackyStringInterface.
• You must use the provided MyIndexOutOFBoundsException class
• I will run your code against a standard set of test cases to make sure that you implemented the
functionality of the required methods correctly.

Write this program in JAVA and compile it in JDK 8 or better. Follow all commenting conventions discussed in
class and include a comment block at the top of each file with your name, date, the course number and
section.
Upload the project source code file, RamString.java to Gradescope and upload your Test Plan to the link in
Blackboard.

Grading Rubric
RamString class:
Constructors are implemented as specified (5 pts.) _________
Mutator method and instance variable both uphold encapsulation (5 pts.) _________
getEveryThirdCharacter () method written as specified (10 pts.) _________
getEvenOrOddCharacters(String evenOrOdd) method written as specified (10 pts.) _________
countDoubleDigits () method written as specified (10 pts.) _________
isValidVCUEmail () method written as specified (10 pts.) _________
convertDigitsToRomanNumeralsInSubstring () method written as specified (15 pts.) _________
ramifyString() method written as specified (10 pts.) _________
Programming style and readability (Including code comments) (5 pts.) _________
Test Plan:
All methods of RamString are thoroughly tested in Test Plan (20 pt.) _________
Total (100 pts.) _________

CMSC256 Programming Assignment 3

Program: SongList

Points: 100
For this project, you will be searching and sorting song data. The song data will be obtained from an
online dataset and access via the BRIDGES API – https://bridgesdata.herokuapp.com/api/datasets/song.

The dataset structure for the songs consists of the title (as “song”), release_date, artist, album, and
lyrics.
{
“song”: “Happy”,
“release_date”: “2013-11-21”,
“artist”: “Pharrell Williams”,
“album”: “G I R L”,
“lyrics”: “\n\n[Produced by Pharrell Williams]\n\n[Verse 1]\nIt might seem crazy what I’m ’bout to say\nSu
nshine she’s here, you can take a break\nI’m a hot air balloon that could go to space\nWith the air, like I d
on’t care, baby, by the way\n\n[Hook]\n(Because I’m happy)\nClap along if you feel like a room without a r
oof\n(Because I’m happy)\nClap along if you feel like happiness is the truth\n(Because I’m happy)\nClap a
long if you know what happiness is to you\n(Because I’m happy)\nClap along if you feel like that’s what yo
u wanna do\n\n[Verse 2]\nHere come bad news, talking this and that (Yeah!)\nWell, give me all you got, d
on’t hold it back (Yeah!)\nWell, I should probably warn ya, I’ll be just fine (Yeah!)\nNo offense to you, don’t
waste your time, here’s why…\n\n[Hook]\n(Because I’m happy)\nClap along if you feel like a room without
a roof\n(Because I’m happy)\nClap along if you feel like happiness is the truth\n(Because I’m happy)\nCl
ap along if you know what happiness is to you\n(Because I’m happy)\nClap along if you feel like that’s wh
at you wanna do\n\n[Bridge]\nBring me down\nCan’t nothing bring me down\nMy level’s too high to bring
me down\nCan’t nothing bring me down, I said…\nBring me down\nCan’t nothing bring me down\nMy leve
l’s too high to bring me down\nCan’t nothing bring me down, I said…\n\n[Hook]\n(Because I’m happy)\nCl
ap along if you feel like a room without a roof\n(Because I’m happy)\nClap along if you feel like happiness
is the truth\n(Because I’m happy)\nClap along if you know what happiness is to you\n(Because I’m happy
)\nClap along if you feel like that’s what you wanna do\n(Because I’m happy)\nClap along if you feel like a
room without a roof\n(Because I’m happy)\nClap along if you feel like happiness is the truth\n(Because I’
m happy)\nClap along if you know what happiness is to you\n(Because I’m happy)\nClap along if you feel
like that’s what you wanna do\n\n[Bridge]\nBring me down\nCan’t nothing bring me down\nMy level’s too
high to bring me down\nCan’t nothing bring me down, I said…\nBring me down\nCan’t nothing bring me d
own\nMy level’s too high to bring me down\nCan’t nothing bring me down, I said…\n\n[Hook]\n(Because I’
m happy)\nClap along if you feel like a room without a roof\n(Because I’m happy)\nClap along if you feel li
ke happiness is the truth\n(Because I’m happy)\nClap along if you know what happiness is to you\n(Beca
use I’m happy)\nClap along if you feel like that’s what you wanna do\n(Because I’m happy)\nClap along if
you feel like a room without a roof\n(Because I’m happy)\nClap along if you feel like happiness is the truth
\n(Because I’m happy)\nClap along if you know what happiness is to you\n(Because I’m happy)\nClap alo
ng if you feel like that’s what you wanna do\n\n”
}

You are to obtain the song data and Song objects using the BRIDGES API via the
bridges.connect.DataSource and bridges.data_src_dependent.Song classes. To
provide customized sorting of the song data, you are to write a SongComparator class that implements
the java.util.Comparator interface for bridges.data_src_dependent.Song objects.
A second class is to be written called SongList that contains a main method.

The program is to:
• Read song data from the BRIDGES song dataset
• Read an artist name as a command line argument. If a command line argument is not provided,
prompt the user to enter an artist name.
• Provide method that returns a formatted list of all the songs by that artist that appear on the
playlist, grouped by album and in alphabetical order by song title. The name of the method
must be:
public String getSongsByArtist(String artist)
• The returned String is to be formatted with each song on a separate line with the song title,
artist and album labeled as shown here:

Title: Harder, Better, Faster, Stronger Artist: Daft Punk Album: Discovery
• If no songs by the given artist are on the playlist, an appropriate message is to be displayed.
It is expected that your program will be well documented, and must contain a comment block at the
beginning that includes the following information in an easy-to-read format: the file name, your name,
the project number, the course identifier (CMSC 256), and the current semester, and a brief description
of the file’s purpose.

Build both files inside of a cmsc256 package. Submit the individcual Java files to the Project 3 link in
Gradescope. Do not compress the files, they should both be submitted as a single submission of two
individual files.

CMSC256 Programming Project 4 – Custom Stack Implementation

In this project you will implement a Stack.

1. You will write a CustomStack class that implements the StackInterface shown here: package cmsc256; public interface StackInterface { /** Adds a new entry to the top of this stack. @param newEntry An object to be added to the stack. */ public void push(E newEntry); /** Removes and returns this stack’s top entry. @return The object at the top of the stack. @throws EmptyStackException if the stack is empty before the operation. */ public E pop(); /** Retrieves this stack’s top entry. @return The object at the top of the stack. @throws EmptyStackException if the stack is empty. */ public E peek(); /** Detects whether this stack is empty. @return True if the stack is empty. */ public boolean isEmpty(); /** Removes all entries from this stack. */ public void clear(); }

2. The class will use the BRIDGES Slelement class to represent an element in the stack. The SLelement class represents a singly-linked node. More information and a sample program can be found here – http://bridgesuncc.github.io/tutorials/SinglyLinkedList.html

3. To view the contents of the stack you will need a display() method within the CustomStack class that will provide an output of the stack. The following code may be used: public void display() { if(isEmpty()) { System.out.println(“The stack is empty”); } else { SLelement current = topNode; StringBuffer output = new StringBuffer(); output.append(“Top of stack: ” + current.getValue() + “\n”); while(current.getNext() != null) { current = current.getNext(); if(current.getNext() == null) output.append(“Stack bottom: “); else output.append(” “); output.append(current.getValue() + “\n”); } System.out.println(output.toString()); } }

4. Add a main method to demonstrate your implementation on a stack of integer by performing a sequence of push and pops and output the stack contents. Here is example: Pushed 256, 10, 18, 20, and 2018 Top of stack: 2018 20 18 10 Stack bottom: 256 Called pop twice: Top of stack: 18 10 Stack bottom: 256 A call to peek returns 18 Top of stack: 18 10 Stack bottom: 256 Called pop three times: The stack is empty

5. Use the BRIDGES visualizer to display the contents of the full stack, before any elements are popped off. Your file must be written in a specific package – cmsc256 and will be uploaded to Gradescope for grading.

Follow the Coding Style Guideline in Blackboard and include a comment block that includes your name, the name of the project along with the file name and a brief description of the purpose of the class at the top of the source code file that you submit. Ask questions about any part of the programming project that is not clear!

CMSC256 Programming Project 5 – Binary Search Tree Implementation

In this project you will implement a Binary Search Tree using bridges.base.BinTreeElement as the node and by implementing the provided BinTreeInterface.

1. Provide an implementation of the BinTreeInterfaceinterface as a class named BinSearchTree

2. In the BinSearchTree class, implement the following new methods: • /** Return the height of this binary tree */ public int height() • /** Returns true if the tree is a full binary tree */ public boolean isFullBST() • /** Return the number of leaf nodes */ public int getNumberOfLeaves() • /** Return the number of non-leaf nodes */ public int getNumberOfNonLeaves()

3. Include a main method that adds the following elements to the tree and visualize the tree in Bridges: BinSearchTree names = new BinSearchTree<>(); names.add(“Frodo”); names.add(“Dori”); names.add(“Bilbo”); names.add(“Kili”); names.add(“Gandalf”); names.add(“Fili”); names.add(“Thorin”); names.add(“Nori “);

Upload the URL for your visualization along with a screenshot that includes your webpage with a title and your name using the setTitle and/or setDescription mehods on your Bridges object.

Your file must be written in package – cmsc256. Upload only the BinSearchTree class to Gradescope for grading.

Follow the Coding Style Guideline in Blackboard and include a comment block that includes your name, the name of the project along with the file name and a brief description of the purpose of the class at the top of the source code file that you submit. Ask questions about any part of the programming project that is not clear.

CMSC256 Programming Project 6 – Graph Application and Implementation

In this project you will extend the UnweightedGraph class by implementing a class called MyGraph that adds functionality for the following five methods:

Test whether a graph is connected

1. Add a method called isGraphConnected that reads a graph from a file and determines whether the graph is connected. o The header for this method is public boolean isGraphConnected(String fileName) o Your method will accept a file name as a String parameter and if the file is unable to be opened, the method should throw a FileNotFoundException o

The first line in the file contains a number that indicates the number of vertices (n). o The vertices are labeled as 0, 1, …, n−1. o Each subsequent line, with the format u v1 v2 …, describes edges (u, v1), (u, v2), and so on. Here are examples of two files for their corresponding graphs: Hint: The method should read data from the file, create an instance g of UnweightedGraph, invoke g.printEdges() to display all edges, and invoke dfs() to obtain an instance tree of UnweightedGraph.SearchTree. If tree.getNumberOfVerticesFound() is the same as the number of vertices in the graph, the graph is connected.

Find connected components

2. Add a method called getConnectedComponents() for finding all connected components in this graph instance with the following header: public List<List> getConnectedComponents() o The method returns a List<List>. Each element in the list is another list that contains all the vertices in a connected component.

Find paths

3. Add a method called getPath for finding a path between two vertices with the following header: public List getPath(int u, int v) o The method returns a List that contains all the vertices in a path from u to v in order. o Using the BFS approach, you can obtain the shortest path from u to v. o If there isn’t a path from u to v, the method returns null.

Detect cycles

4. Add a method called isCyclic() for determining whether there is a cycle in the graph with the following header: public boolean isCyclic() o The method returns true if there is a cycle in this instance of MyGraph.

Find a cycle

5. Add a method called findCycle that will find a cycle in this graph that starts at vertex u with the following header: public List findCycle(int u) o The method returns a List that contains all the vertices in a cycle starting from u o If there is not a cycle in this instance of MyGraph, the method returns null. Your file must be written in package – cmsc256 .

Upload both the MyGraph class and the MyGraphTest class to Gradescope for grading. Follow the Coding Style Guideline in Blackboard and include a comment block that includes your name, the name of the project along with the file name and a brief description of the purpose of the class at the top of the source code file that you submit. Ask questions about any part of the programming project that is not clear.