Categories
Java

Part 1: An Implementation of DefaultMap (17 points) You’ll provide a fast implem

Part 1: An Implementation of DefaultMap (17 points)
You’ll provide a fast implementation of an interface called DefaultMap in MyHashMap.java.
You will implement all the methods defined in the DefaultMap interface. Using amortized analysis, you must ensure that each has the specified big-O bound and argue why based on the documentation of any libraries you use or based on your implementation. In each, n represents the number of entries in the map.
Here is a helpful link to learn more about amortized analysis that gives an example with a dynamic array: http://www.cs.cornell.edu/courses/cs3110/2011sp/Le…
put, required O(1)
replace, required O(1)
remove, required O(1)
set, required O(1)
get, required O(1)
size, required O(1)
isEmpty, required O(1)
containsKey, required O(1)
keys, required O(n)
In MyHashMap.java you will implement a single constructor that takes two arguments (the initial capacity and the load factor). This is where you will initialize the instance variables.
HashMapEntry
Within MyHashMap.java, you are provided the private inner class HashMapEntry. Use this class to represent your key value pairs in your HashMap. Note it implements the DefaultMap.Entry interface. Each HashMapEntry object has two instance variables (K key, V value). Use the getters/setters from this class to get the key values and set the values.
Instance Variables
loadFactor: the load factor for when to increase the capacity of the HashMap (default = 0.75)
capacity: the overall capacity of the HashMap (initial default = 16)
size: the number of elements in the HashMap
buckets or entries: If you would like to using Separate chaining conflict resolution, use the List array buckets. If you would like to use Linear Probing for your conflict resoultion, use the array entries. For either case, buckets or entries is where your elements will be stored. However, we strongly recommend handling collision using separate chaining.
Note: initialCapacity must be non-negative and loadFactor must be positive. If either of these conditions are violated, you must throw an IllegalArgumentException in your constructor with the appropriate error message.
The specifications for the other methods are defined in header comments in the DefaultMap.java file, which you should follow. You may use any methods in the Java collections library to implement them (including helpers like Collections.sort). If you don’t know how to use a particular library method, interface, or class in the standard Java utils, ask! This is an opportunity to learn about the built-in libraries. Note: You are not allowed to use the java HashMap library!!!
You may find these useful:
Set
Collection
The pages linked from those may also have useful information. For specific hash map implementation detail, please follow your implementation based on lecture. Your implementation of DefaultMap will be graded automatically by tests that we provide.
Note: Please make sure that you test your MyHashMap implementation thoroughly before proceeding to part 2 as you will be using your implementation of MyHashMap in part 2.
Part 2: File System Implementation (16 points)
You are asked to implement a basic unix file system structure to support files look up methods. It is shown in the log history that users tend to search files either by their names, their directories, or their modified dates. After implementing MyHashMap in part 1, you think that a hash map will be a perfect data structure for this task to perform these searches in an efficient way. Your task is to design a simplified file system structure with a hash map that can support users defined filtering methods while making sure that those filtering methods are performed in an efficient way.
You should only modify FileSystem.java and FileData.java for implementation of the file system.
Note: It’s likely that you need to store multiple files with the same name in your computer, therefore our file system support duplicate files with the same name or date in different directories. However, the name should always be unique in each directory.
FileData
In our file system, a file is represented as a FileData object which contains the information of its name, directory, and last modified date.
Instance VariablesnameThe name of the given file in string format.
dirThe directory of where the file is stored in, represented in a string format.
lastModifiedDateThe date of when the file is last modified, represented in a string format.
MethodsIn FileData.java, you will implement and thoroughly test the following methods:
public FileData(String name, String directory, String modifiedDate)
public String toString()
public FileData(String name, String directory, String modifiedDate)A Constructor that creates an instance of FileData object by intializing its instance variables with the given parameters. You may assume that the parameters passed in to the constructor will be non-null.
public String toString()A method that returns the string representation of FileData by displaying the file information. It should strictly follow the format of {Name: file_name, Directory: dir_name, Modified Date: date}.
FileSystem
In our file system, FileSystem class will be used to represent the entire structure of the file system. You should store file’s information in the instance variable provided to ensure that the look up times are as efficient as possible. You are NOT ALLOWED to add any additional instance variables or to include any additional imports in FileSystem.java.
Instance VariablesnameMapA MyHashMap that uses file name as the key and a list of FileData as the value. *Illustration to show that “test.txt” is an entry within nameMap that uses filename (String) as a key that maps to an arraylist of all fileData with the same filename but in a different directory.
dateMapA MyHashMap that uses file’s date as the key and a list of FileData as the value. *Illustration to show that “02/01/2021” is an entry within nameMap that uses file’s lastModifiedDate (String) as a key that maps to an arraylist of all fileData with the same lastModifiedDate.
MethodsIn FileSystem.java, you will implement and thoroughly test the following methods:
public FileSystem()
public FileSystem(String fileInfo)
public boolean add(String fileName, String directory, String modifiedDate)
public FileData findFile(String name, String directory)
public ArrayList findAllFilesName()
public ArrayList findFilesByName(String name)
public ArrayList findFilesByName(String modifiedDate)
public ArrayList findFilesInMultDir(String modifiedDate)
public boolean removeByName(String name)
public boolean removeFile(String name, String directory)
public FileSystem()Default constructor that creates a new FileSystem object and initializes its instance variable.
public FileSystem(String inputFile)Constructor that creates a new FileSystem object with the given inputFile that contains the file system information. We have provided some skeleton code for reading the contents of the text file. You will need to initailizes FileSystem’s instance variables and populate FileSystem with each file’s information. Each file information is represented by a line formatted as filename, directory, date within the content of inputFile. For example, it could be mySample.txt, /home, 02/01/2021. (Note that since it is a unix type file system, forward slashes are used to represent directory hierarchy). We have also provided a sample file, input.txt, to show how each file information is represented within the inputFile. Feel free to add more data to the file to test your FileSystem implementation thoroughly. You may assume that inputFile parameter is properly formatted and is non-null.
public boolean add(String fileName, String directory, String modifiedDate)This method should create a FileData object with the given file information and add it to the instance variables of FileSystem. This method should return true if the file is successfully added to the FileSystem, and false if a file with the same name already exists in that directory. The default values for filenName, dir, and modifiedDate are “”, “/”, “01/01/2021” in case any of these variables is null.
public FileData findFile(String name, String directory)This method should return a single FileData object with the given name and directory. You should not modify the FileSystem itself. Return null if such a file does not exist.
public ArrayList findAllFilesName()This method should return an array list of string that represents all unique file names across all directories within the fileSystem. You should not modify the FileSystem itself. Return an empty array list if there is no file in the file system yet.
public ArrayList findFilesByName(String name)The find method should return a list of FileData with the given name. You should not modify the FileSystem itself. Return an empty list if such a file does not exist.
public ArrayList findFilesByDate(String modifiedDate)This find method should return a list of FileData with the given modifiedDate. You should not modify the FileSystem itself. Return an empty list if such a file does not exist.
public ArrayList findFilesInMultDir(String modifiedDate)This find method should return a list of FileData with the given modifiedDate that has at least another file with the same file name in a different directory. You should not modify the FileSystem itself. Return an empty list if such a file does not exist.
public boolean removeByName(String name)This method should remove all the files with the given name in the FileSystem. Return true if success, false otherwise. Remove the entry in the hashmap if necessary.
public boolean removeFile(String name, String directory)This method should remove a certain file with the given name and directory. Return true if success, false otherwise. Remove the entry in the hashmap if necessary.
Testing (3 points)
In the starter code, there are three files where you may add tests:
MyHashMapTest.java
FileSystemTest.java
FileDataTest.java
Write at least two tests per file and submit these to Gradescope along with your implementations. This section will be graded based on completion.
Part 3: Gradescope Assignment (9 points)
Gradescope Question
You will write answers to the following question on Gradescope:
For each method in MyHashMap (excluding size and isEmpty), argue why its performance meets the specified required bound.
Style (5 points)
The following files will be graded on style:
MyHashMap.java
FileSystem.java
FileData.java
To find the full style guideline, follow this link: https://docs.google.com/document/d/1XCwv_vHrp1X4vm…
All guidelines that we will be following this quarter are marked in the Style Guidelines document. These are required and will be graded.
On this PA, all guidelines must be followed, they are summarized below:
file headers
method headers (not required for test methods)
Lines cannot be longer than 100 characters
Inconsistent indentation
Lines must not be indented more than 6 times. If you have a need to indent more than 6 levels, build a helper method or otherwise reorganize your code
Test method must have meaningful names
Helper method must have meaningful names
descriptive variable names
magic numbers
Answers for FAQ
FileNotFound ExceptionIf you receive FileNotFound exception when instantiating FileSystem with input.txt in Eclipse Window, make sure to place input.txt in the correct directory since Eclipse for Windows puts the files at the project root, not the bin or src.
Clarification on findFilesInMultDirFor example, if we have following entries in input file: test.txt, /home, 01/01/01 test.txt, /root, 01/01/01 sample.txt, /home, 01/01/01 sample.txt, /root, 02/01/01 text, /home, /02/01/01. Calling findFilesInMultDir(“01/01/01”) should return you an array list of {Name: test.txt, Directory: /home, Modified Date: 01/01/01}, {Name: test.txt, Directory: /root, Modified Date: 01/01/01}, {Name: sample.txt, Directory: /home, Modified Date: 01/01/01}.
Amortized Analysis ExplanationAmortized Analysis allows us to find a tight bound on the worst case. Sometimes data structures will have a costly operation (for example, the HashTable has expandCapacity). However, this operation is not performed very often. Because of this, the data structure should not be considered a costly structure. This is when we would use amortized analysis to average out the costly operations when finding the worst case.
Example: HashTable set() In the worst case, this would be O(n).
However, we are not calling expandCapacity at every step, so this is not a tight worst case bound. With amortized analysis, we can look at how often expandCapacity and find the average cost for the operations. In the image below, we have an example of the cost of adding a value n times.
We can see that expandCapacity occurs at the 2nd, 3rd, 5th and 9th steps. We then average the costs over the number of elements that were added and find that the upper bound is 3 which is O(1). So the tight bound for the worst case is O(1). This can also be considered the average case. So in summary, the amortized analysis focuses on the worst-case runtime per operation rather than per algorithm. It allows us to accurately measure the performance of different data structures that might have occasional costly operations.
Submitting
Part 1 & 2On the Gradescope assignment Programming Assignment 6 – code please submit the following files:
MyHashMap.java
MyHashMapTest.java
FileSystem.java
FileSystemTest.java
FileData.java
FileDataTest.java
The easiest way to submit your files is to drag them individually into the submit box and upload that to Gradescope. You may submit as many times as you like till the deadline.
Part 3Please submit your answers to the questions from part 3 on the Gradescope assignment Programming Assignment 6 – questions. You may submit as many times as you like till the deadline.
Scoring (50 points total)
17 points: implementation of DefaultMap [automatically graded]
16 points: implemetnation of FileSystem and FileData [automatically graded]
3 point: MyHashMapTest, FileSystemTest, and FileDataTest graded on completition [manually graded]
9 points: Gradescope Questions [manually graded]
5 points: Style [manually graded]
There is no bad implementation testing on this PA. However, we highly recommend you use the practices you know from testing to thoroughly check that MyHashMap and the FileSystem you wrote work as expected.

Categories
Java

2) documentation

Use the Link below as your starting point to reproduce the same concept of the Author. This is a JavaFX and Java sockets program for Server -Client Messenger.
The idea here is your ability to understand all the concepts of JavaFX in a project.
I would like you to produce a replica of the project in your Lab and (possible improve the Project through your Enhancement)-25-%
Deliverables:
1) Source codes
2) Documentation 3) Screenshots of Panes
3.1) Edit the information in the pan with your student ID.
4) Suggestion for Improvements

Categories
Java

Does findcounterexample correctly return some counterexample for this implementation?

File Summary
PartitionOracle.java:findCounterExample (you implement this)
generateInput (you implement this)
isValidPartitionResult (you implement this)
TestPartitionOracle.java: You will write your tests of the methods above here
CounterExample.java (do not edit this)
Partitioner.java (do not edit this): Defines the signature of the partition method implemented by all sorters. You will implement this interface several times to test findCounterExample.
WebPartitioner.java:For your implementation found on the Web that you will adapt to implement Partitioner
CentralPivotPartitioner.java:A concrete class which implements Partitioner and utilizes a central pivot (you implement this)
FirstElePivotPartitioner.java:A concrete class which implements Partitioner and utilizes the first element as the pivot (you implement this)
Part I: A Bad (and Good) Implementation Detector
Testing with Properties
So far in this class, we have usually written tests by following this process:
Construct the input data
Perform an operation
Check that the resulting data is equal to some expected value
This works well for writing a small or medium number of tests targeted at particularly interesting cases. Checking specific output values, however, isn’t the only or necessarily the best way to test and gain confidence in an implementation. In fact, sometimes it won’t work at all.
Consider the partition helper method of quick sort as an interface (here we’ll restrict it to just partitioning arrays of Strings):
interface Partitioner {
// Change strs between start (inclusive) and end (exclusive), such that
// all values at indices lower than a pivot index are smaller than or equal
// to the value at the pivot, and all values at indices higher than the pivot
// are larger than or equal to the value at the pivot
int partition(String[] strs, int start, int end);
}
In lecture and discussion, we noted that there are many ways to implement partition, in particular the choice of the pivot index is important. Not only could we choose different pivots, but one choice is to have a random choice of pivot! Let’s imagine writing a test for a Partitioner:
class PartitionerFromLecture implements Partitioner {
public int partition(String[] strs, int low, int high) {
int pivotStartIndex = Random.nextInt(high – low);
… implementation from lecture …
}
}
@Test
public void testPartitionerFromLecture() {
Partitioner p = new PartitionerFromLecture();
String[] input = {“z”, “b”, “a”, “f”};
int pivot = p.partition(input, 0, 4);
assertArrayEquals(???, input); // What to expect?
assertEquals(???, pivot);
}
For two items, there are some clever solutions. You can use special matchers, for instance.
Instead of writing out all the tests by hand, we should step back from the problem. We really care that the array is correctly partitioned – there shouldn’t be elements larger than the pivot value at earlier indices, or elements smaller than the pivot value at later indices. There are other properties, too, like all the elements that were in the input list should appear the same number of times in the output list – if partition duplicates or loses elements, it isn’t doing its job!
So, instead of writing single tests, we should write methods that, given a partition algorithm, check if it satisfies some desired properties that partitioning ought to. Properties sufficient to show a valid partitioning are:
All the elements in the original array are present in the array after we call partition
No values at indices other than those from low (inclusive) to high (exclusive) changed their values
The elements from low to high are correctly partitioned:partition returns some pivot index between low (inclusive) and high (exclusive)
At all indices from low up to the pivot index the string is smaller than or equal to (according to compareTo) the value at the pivot index
At all indices from the pivot index up to high – 1, the string is larger than or equal to (according to compareTo) the value at the pivot index
Your Task
You will turn the properties above into code that checks if a given result from partition is valid. That means your program will decide, for any call to partition, if it behaves as we’d expect. Further, we can extend this idea to build a method that takes a Partitioner and returns null if we believe it to be a good partitioner, and a CounterExample if we can find an input array and low/high bounds that partition incorrectly:
CounterExample findCounterExample(Partitioner p);
CounterExample is defined to contain:
The input to a call to partition (an array, a low index, and a high index)
The result of a call to partition (an array and a returned pivot index)
A reason, as a String, that you choose in order to describe why it is invalid. Some suggestions are below.
You will write a version of CounterExample and use it to check multiple different partition implementations, some good and some bad. Note that, even beyond the argument above about randomness, there are multiple possible correct implementations of partition.
You must implement two methods to help you implement CounterExample; you can implement other helpers as you see fit. The two methods you must implement are:
/*
* Return null if the pivot and after array reflect a correct partitioning of * the before array between low and high.
*
* Return a non-null String (your choice) describing why it isn’t a valid
* partition if it is not a valid result. You might choose Strings like these,
* though there may be more you want to report:
*
* – “after array doesn’t have same elements as before”
* – “Item before pivot too large”
* – “Item after pivot too small”
*/
String isValidPartitionResult(String[] before, int low, int high, int pivot, String[] after)
/*
* Generate a list of items of size n
*/
String[] generateInput(int n);
This method should create a list of items to use as input to purported partition algorithms. It’s up to you how it generates the items; it should produce an array of length n, however.
An Overall Strategy
Here’s one way you might approach this problem:
First, implement and test isValidPartitionResult. Think of several interesting individual cases (specific arrays and low/high bounds) you can imagine in a first pass, and test it on those cases. Note that to test isValidPartitionResult, you will be creating pairs of arrays of strings for input and expected output (at first, by hand), and checking both for success and for failure: you should have some tests where the after parameter and pivot describe an incorrect partitioning, and some correct.
Implement generateInput in a simple way – make n Strings of random single characters. Test that the method returns the right number of elements without any errors.
Implement a (really) incorrect version of Partitioner, that makes no changes at all to the underlying array in its partition method. Implement a good version of Partitioner as well (you can take the one from class/discussion), adapted to work as a Partitioner.
Try putting together a first version of findCounterExample. It could create a single list using generateInput, partition it with the given partitioner, check if it was sorted correctly using isValidPartitionResult, and return null if it partitioned correctly or a CounterExample if it didn’t. Note: you will need to save the original array, since sorters can and will make changes to them! You can use Arrays.copyOf to make a copy of an array:String[] input1 = {“a”, “b”, “c”, “a”};
String[] original1 = Arrays.copyOf(input1, input1.length);
With this flow, you can test that findCounterExample returns null when passed the good partitioner, and a CounterExample when given the bad partitioner. The testing methods assertNull and assertNotNull can be helpful here.
Note that you should generate multiple lists and test several partitions in findCounterExample to properly vet each partitioner.
You can write these tests in TestPartitionOracle.java (yes, the tester has its own tests!). This will get you through the beginning of the problem, and familiar with all the major interfaces. With this in hand, you can proceed with more refined tests. Here are some ideas:
Make a copy of the good Partitioner you wrote, and change it in a subtle way, maybe change a < to a <= in comparison or vice versa. Is it still a good partitioner? Can your findCounterExample check that?
Make a copy of the good Partitioner you wrote and change it in an obviously breaking way, maybe by setting an element to the wrong value. Does findCounterExample correctly return some CounterExample for this implementation?
Change findCounterExample to call generateInput many times, and check that all the generated lists sort correctly, returning the first failure as a CounterExample if it didn’t.
Feel free to add some interesting hand-written cases to findCounterExample where you use interesting input lists that you construct by hand. You can combine whether they sort correctly or not (e.g. partition them and then check isValidPartitionResult).
Use the two partition implementations that you wrote and the implementation you found on the web (below) to check if they are good or bad.
The java.util.Random class has useful tools for generating random numbers and strings. You can create a random number generator and use it to get random integers from 0 to a bound, which you can combine with ASCII codes to get readable random strings:Random r = new Random();
int asciiForACapLetter = r.nextInt(26) + 65; // Generates a random letter from A – Z
String s = Character.toString((char)(asciiForACapLetter));
You may find it useful to copy the arrays into lists so you can remove elements and use other list operations in your oracle. This is a useful one-line way to copy an array into an ArrayList:List afterAsList = new ArrayList(Arrays.asList(after));
Overall, your goal is to make it so findCounterExample will return null for any reasonable good partition implementation, and find a CounterExample for any bad partition implementation with extremely high probability. We will provide you with a bunch of them to test against while the assignment is out, and we may test on more than we provide you in the initial autograder.
We won’t test on truly crazy situations, like a partitioner that only fails when passed lists of 322 elements, or when a one of the strings in the array is “Henry”. The bad implementations will involve things logically related to sorting and manipulating lists, like boundary cases, duplicates, ordering, length, base cases, and comparisons, as a few examples.
What to do about null?
Assume that there are no null items in the arrays, that sorts won’t putnull items in the arrays, and that the variables holding lists of items won’t contain null. There are plenty of interesting behavior to consider without it!
Don’t have your implementation of findCounterExample take more than a few seconds per sorting implementation. You don’t need to create million element lists to find the issues, and it will just slow down grading. You should focus on generating (many, maybe hundreds or thousands of) small interesting lists rather than a few big ones, which should process very quickly.
Part II: Implementing Different Partitions
When you’re learning, it’s useful to write implementations yourself to gain experience. Your task now will be to write three partition methods that differ in the way they choose the initial pivot value. There are many different way to choose the pivot value, but the two we ask you to implement are listed below. You are welcome to search for solutions on the internet to solve this portion of the PA. Include a link to wherever you found an internet solution if you do use a solution from the interent.
Central Pivot Value: The initial pivot value should be chosen as the middle index in the similar range as above. For example if start is 1 and end is 4, the middle index should be 2.
First index as Pivot Value: The initial pivot value should be chosen as the first index, i.e the value at the index, start.
Put these implementations in the corresponding files:
CentralPivotPartitioner.java
FirstElePivotPartitioner.java
All these files should contain classes that implement the Partitioner interface, which means that the partition method you are expected to implement should follow the method signature provided in that interface. Both implementations will return the final pivot position and maintain the correct behavior where all values that are less than the pivot should be stored before it and all values greater than the pivot should be store after it. One way to check whether your implementations are correct is to use findCounterExample from part I to determine if a counterexample can be generated for your partition, provided that your code from part I is correct and thorough. If a counterexample is generated that means that there is likely an error and you can use that to debug your program.
Part III: Copying Code from the Internet
There’s a lot of code out there in the world. Much of it is available, with permissive licensing, for free on the Web. When you’re learning, it’s often useful to write implementations yourself to gain experience. However, there are also skills related to finding and re-using code, rather than writing your own from scratch. These skills are useful to develop, and come with their own set of best practices.
When you re-use or repurpose code, there are two main concerns:
Are you allowed, legally and ethically? Your course, company, or institution may have its own rules, and there are laws about how you can re-use or modify code depending on its software license. There are also simple intellectual honesty issues around giving credit to the right sources. It may be the case that you shouldn’t even be looking at other code that solves your problem. This is usually the case in programming courses, for example.
More practically, does the code actually do what you want? If it’s a method, are the inputs and outputs the types your program will expect? Does it match your performance expectations in terms of its runtime? If you need to change it to adapt to your application, will that invalidate any assumptions of the original version?
For this assignment, you must go find a single partition implementation in Java on the Web. You should document the source you got it from clearly, and adapt it to fit the Partitioner interface that partitions Strings. For each implementation you find, you write in a header comment with the method:
Where it came from as a URL, and list the author (usernames or emails count!) if you can identify the author
A URL for the license or other rules posted for the re-use of the code. In code repositories like those on Github, this will usually be in a file called LICENSE or LICENSE.txt in the root of the repository. Here’s one for openjdk, a free and open source Java implementation, for example. Don’t use code for which you can’t find the rules of re-use!
Describe what changes you made to adapt it to this problem
Indicate if it was buggy or not (by using handwritten tests, or potentially by using your tester, if you have it ready) and why
Describe the worst case of its runtime behavior using a tight big-O bound
Put the implementation you adapt in the provided file WebPartitioner.java.
A search engine is your friend here. Searching “Java partition implementation” or “Java quicksort implementation” is a fine way to start. Searching “java partition implementation site:github.com” gives a bunch of promising options, as well. Have fun searching, there’s lots of cool stuff out there!
NOTE: This part of the assignment comes with a deliberate, narrow exception to the Academic Integrity policy for the course. You shouldn’t, in any other assignment (or other parts of this assignment) go hunting for code on the Web that solves the assignment for you. You certainly shouldn’t do it in other classes or at your job unless you know it’s acceptable to do so – you should always know and consult the policies relevant to your current context. We (the instructors) know how to search for code on the Web. So do intellectual property attorneys, to extend the analogy to the professional context.
Asking for Help
The coding task for this assignment is to implement and test findCounterExample along with the two partition methods. You are free to go to help hours for assistance, but be aware that tutors may not be able to directly answer your questions or debug your program.
Answers to FAQ
The input arrays are string arrays of letters, not numeric strings like {“1”, “2”, “3”}.
The implementation of generateInput() is completely up to you, as long as you generate n items for your string array
If you receive a TimeOutException in the tests, this means that your code takes too long to run a specified test on Gradescope. You may want to check for infinite loops inside of your own code. It also means your code might be crashing and throwing an exception (such as IndexOutOfBoundsException).
You are allowed to use code from lecture slides, discussion slides/videos, and zybooks.
We will not be testing invalid low/high values, nor will we test empty arrays.
If you are receiving a TimeOutException for the PartitionBad implementations, try using values other than high=array.length in your findCounterExample.
When low == high, the partition method should not change the array passed in. You can, but are not required to account for this case in your partition implementations because this is technically invalid input. Therefore, you should not use low == high input in your findCounterExample.
File headers are not a part of the style guidelines, similar to PA3.
Please remove any and all main methods that you added to your code for testing before submitting.
For an implementation of partition() you find online, as long as you find the url for its source and license for use (e.g. Creative Commons, MIT, etc.), you can use that implementation for your WebPartitioner.
You don’t need to intentionally find a buggy web partitioner, but you do need to indicate if your partitioner is buggy.
Style
The style guidelines are the same as PA3, with the following additions:
Lines must not be indented more than 6 times. If you have a need to indent more than 6 levels, build a helper method or otherwise reorganize your code.
If you write a helper method with a body longer than 2 statements, you must add a header comment (a comment above the method) that summarizes what it does in English.
The remark about redundant inline commenting from PA3 is still a recommendation, not something we will enforce.
Submission
On the Gradescope assignment Programming Assignment 5 – code please submit the following files:
PartitionOracle.java
TestPartitionOracle.java
CounterExample.java
Partitioner.java
WebPartitioner.java
FirstElePivotPartitioner.java
CentralPivotPartitioner.java
You may encounter errors if you submit extra files or directories. You may submit as many times as you like till the deadline.
Scoring (40 points total)
10 points: isValidPartitionResult, graded automatically
5 points: generateInput, graded automatically
11 points: findCounterExample, graded by how it performs on good and bad partitions that we provide, graded automatically
6 points: (3 points each) for CentralPivotPartitioner.java and FirstElePivotPartitioner.java, graded automatically
3 points: The sort implementation you find online and describe [manually graded]
5 points: Test and code readability and style [manually graded]

Categories
Java

It has to be four different classes which are one abstract class, one interface and two concrete classes inhert the abstrac and interface class.

This is the group project and we have to design our own program that meets all the requirements. The requirements for the project have attached below.
Our idea for this project is to create eight different kind of bank which are U.S, Euro, Japanese, Australia, China, Mexico, Canada, and Vietnam which convert the currency these bank. For example: I can you program to change from the Vietnamdong to Jappanese yen and Japanese Yen to Vietnamdong.
The specific requirement have attached with this questions.
it has to be four different classes which are one abstract class, one interface and two concrete classes inhert the abstrac and interface class.

Categories
Java

Doesn’t replace ram 2500 -20%

A. F22 – Car App (ArrayList)
Create an App that allows you to track different vehicles. Declare a String ArrayList for cars. Add the following cars to your list (pg 473): Mercedes, Mustang GT, Odyssey, Porsche, Corvette, Lincoln, Xterra, Camry, Silverado, and Ram 2500. Print a report title line. Print the ArrayList using a loop that uses the ArrayList size to know when to stop (pg 474). Then, Insert Tacoma before Lincoln (pg477). Replace the Ram 2500 with your favorite vehicle (pg478). Print another report title line stating “after update”. Print the ArrayList the second time using the Enhanced for loop (pg 474). You don’t need to use classes or methods for this assignment. You don’t need to get input from the user (Scanner or JOptionPane).
Sample Output:
*** List of Cars ***
Mercedes
Mustang GT
Odyssey
Porsche
Corvette
Lincoln
Xterra
Camry
Silverado
Ram 2500
*** Cars after update ***
Mercedes
Mustang GT
Odyssey
Porsche
Corvette
Tacoma
Lincoln
Xterra
Camry
Silverado
F250 Super Duty
Hints
You can use string literals (“Mercedes”) instead of asking the user for the cars. This will make it easier to test.
Put a n at the start of the second report heading line so it looks more professional
Make sure to use the correct subscript when inserting Tacoma before Lincoln.
Rubric
Doesn’t use the ArrayList -100%
Doesn’t insert Tacoma before Lincoln – 20%
Doesn’t replace Ram 2500 -20%
Doesn’t print the original ArrayList -20%
Doesn’t use ArrayList size to print the ArrayList -5%
Doesn’t print the report title line for the original ArrayList -2%
Doesn’t print the ArrayList the second time -20%
Doesn’t use the enhanced for loop to print the second time -5%
Doesn’t print the “after update” line for the second print -2
B. F22 – Better Electrician AppThis will be similar to the Java 4 Electrician App. You do NOT need to create classes for this assignment. In the main method, ask how many rooms and the price of wire per foot. Create an array of integers that occurs the number of rooms times (pg 404).Write a method to ask for the # of feet of wire for each of the rooms. Pass the array to the method (pg 422). The method should save the number of feet of wire in the elements of the array. Loop through the method for each room. After all rooms have been entered loop through the array to print all the rooms, ex: Room 1 – 22 feet (where the 22 is the number of feet entered for room 1 in the array). Add the number of feet to a variable for the total number of feet. After all rooms have been printed, print the total of all rooms. Add a line that says Waste (add 10%):. Print the final line that has the total of all rooms plus the 10% waste factor and the total cost of the wire (total feet including 10% waste times the price).Sample Output:Room 1 – 15.00 feet
Room 2 – 25.00 feet
Room 3 – 35.00 feet
Total wire for all rooms: 75.00
Total waste (add 10%) : 7.50
Amount of wire needed : 82.50
Price of wire per foot : $ 4.75
Total cost for all wire : $ 391.88Hints/TipsDon’t forget to initialize your accumulator
You must ask for the room count before declaring the array so you know how big to make the array
The method to get the number of feet of wire per room only contains the for loop and the code to ask for the number of feet of wire for each room. The number of feet of wire must be converted (parsed) to a double to put into the array element. Page 406 has an example of inputting array contents, but the book uses 0, 1, 2 (literal values), for the indexes, while we’re using a loop, so our index will be a variable (the control variable in the for loop). Don’t forget that arrays start out at element 0, not 1. Thus, the array length is one more than the largest index (hence, “Off-by-one-Errors – pg 410).
The main method 1) asks for the # of rooms, 2) declares the array, 3) asks for the price, 4) calls the method to load the array, 5) prints the results using a for loop while accumulating the total feet of wire, 6) prints the summary with totals
To use the number of rooms variable in the method, you must pass it to the method along with the array (it doesn’t have access to variables in the calling method).
I used System.out.printf for reporting results
To line up my colons, I put spaces in the literal (ex: “…(add 10%) :”
To line up my numbers, I put 7 after % so that I would print at least 7 characters (ex: %7.2f). 8 would be better if you have total cost over $1,000.
RubricDoesn’t build and use an array -100%
Doesn’t report room details -30%
Doesn’t pass the array to a method -20%
Doesn’t report the array results -30%
Doesn’t sum and calculate total -25%
Incorrect summary info -2% each occurrence

Categories
Java

Write a report (maximum 500 words) to discuss your implementation steps and results.

Develop a Bank Management System with Graphical User Interface in Java. The bank management system is an application for maintaining user account in a bank and develop a banking account system that covers the basic functionality (transactions) of a Bank Account Management System. One should be able to deposit and withdraw money from a particular account and there should be a validation to allow only a particular amount of cash inflows at any time. Allow withdraws if the balance is sufficient. There should also be the calculation of interest and its addition to the balance every month. Identify the system’s objects and develop their required classes. Apply encapsulation by using access modifier and generating their accessors. Allow a class to adopt other classes attributes and methods by using Inheritance. Identify and use the two forms of polymorphism, overriding and overloading. Develop and use abstract classes, abstract methods and interfaces. Develop an application window using Java Window Builder and create a customized frame for your Graphical User Interface. Develop a simplified bank management system that allows user to perform the basic bank’s transactions using Java programming language. Your implementation must be in the graphical user interface (GUI) environment using the Window Builder tool. Write a report (maximum 500 words) to discuss your implementation steps and results.

Categories
Java

Write a report (maximum 500 words) to discuss your implementation steps and results.

Develop a Bank Management System with Graphical User Interface in Java. The bank management system is an application for maintaining user account in a bank and develop a banking account system that covers the basic
functionality (transactions) of a Bank Account Management System. One should be able
to deposit and withdraw money from a particular account and there
should be a validation to allow only a particular amount of cash inflows at any time. Allow withdraws if the balance is sufficient. There should also be the calculation
of interest and its addition to the balance every month. Identify the system’s objects and develop their required classes. Apply encapsulation by using access modifier and generating their accessors. Allow a class to adopt other classes attributes and methods by using Inheritance. Identify and use the two forms of polymorphism, overriding and overloading. Develop and use abstract classes, abstract methods and interfaces. Develop an application window using Java Window Builder and create a
customized frame for your Graphical User Interface. Develop a simplified bank management system that allows user
to perform the basic bank’s transactions using Java programming language. Your implementation
must be in the graphical user interface (GUI) environment using the Window
Builder tool. Write a report (maximum 500 words) to discuss your implementation steps and results.

Categories
Java

#NAME?

Everything you need to know is provided in the PDF however, I would provide the node and linked_list code for exercise one, and I would also provide a skeleton for the maze exercise. Exercise 1) In this exercise you will implement a reverse() function inside the Linked List class to reverse the
order of a linked list. In the driver class, perform the following:
– Populate a linked list with few nodes
– Print your list in order from head – > tail
– Execute the reverse() method
– Print your list in order from head -> tail to verify it was reversed. Exercise 2) 41 rebels are trapped in a cave, surrounded by enemy troops. They decide to commit suicide:
they line up in a circle and systematically kill every other one, going around and around, until
only one rebel is left — who supposedly kills himself (fat chance).
Who is the lone survivor? Exercise 3) Write a program that implements the previous maze using references to instances of a Node class.
Each node in the graph will correspond to an instance of Node. The edges correspond to links that
connect one node to another and can be represented in Node as instance variables that reference
another Node class.

Categories
Java

However, i would also provide a skeleton for the maze exercise.

Everything you need to know is provided in the PDF ( skip exercise 1) . However, I would also provide a skeleton for the maze exercise. Exercise 2) 41 rebels are trapped in a cave, surrounded by enemy troops. They decide to commit suicide:
they line up in a circle and systematically kill every other one, going around and around, until
only one rebel is left — who supposedly kills himself (fat chance).
Who is the lone survivor? Exercise 3) Write a program that implements the previous maze using references to instances of a Node class.
Each node in the graph will correspond to an instance of Node. The edges correspond to links that
connect one node to another and can be represented in Node as instance variables that reference
another Node class.

Categories
Java

Down to 1, then multiply the first array by the second.

Question # 1:
(Filling arrays) Fill a 2-by-3 array with ones, a 3-by-3 array with zeros and a 2-
by-5 array with 7s.
Question # 2: (Broadcasting) Use arange to create a 2-by-2 array containing the numbers 0–3.
Use broadcasting to perform each of the following operations on the original array:
a) Cube every element of the array.
b) Add 7 to every element of the array.
c) Multiply every element of the array by 2.
Question #3:
(Element-Wise array Multiplication) Create a 3-by-3 array containing the even
integers from 2 through 18. Create a second 3-by-3 array containing the integers from 9
down to 1, then multiply the first array by the second.
Question #4:
(array from List of Lists) Create a 2-by-5 array from an argument which is a list
of the two five-element lists [2, 3, 5, 7, 11] and [13, 17, 19, 23, 29].
Question #5:
(Flattening arrays with flatten vs. ravel) Create a 2-by-3 array containing the
first six powers of 2 beginning with 20. Flatten the array first with method flatten, then
with ravel. In each case, display the result then display the original array to show that it
was unmodified.