In this problem, you will complete several classes involving boxes, locks, keys and secrets. Follow the specifications in the starter files for the classes. You can run the javadoc program to generate the API (see Tutorial 2) for the classes.
A box has a secret inside it (and maybe a key!) and can be locked. In order to open a box, you need the right key to unlock the lock. Secrets.java will be a program that takes an array of boxes and an array of keys and tries to open as many boxes as it can with those keys to find as many secrets as possible and returns the Proofs that if found them. Remember, a box can also contain a key to another box!
You need to complete the following classes: Lock, Box, and Secrets. You must submit these files.
The following classes are provided: Key, Proof and Secret. Do not change these classes. We will delete these files if you submit them and use our own copies.
package comp1406a2;
public class Secrets {
/** find all secrets that can be found using the input boxes and keys
*
* @param boxes is a list (arrau) of boxes
* @param keys is a list (array) of keys
* @return a list (array) of proofs for every secret that can be
* extracted from the input boxes and keys. Order does not matter.
*/
public Proof[] findSecrets(Box[] boxes, Key[] keys){
return null;
}
}
public Proof[] findSecrets(Box[] boxes, Key[] keys) {
ArrayList<Proof> proofs = new ArrayList<>();
for(Key k: keys) {
for(Box b: boxes) {
if(b.getLock().unlock(k)) {
proofs.add(new Proof(b.getSecret(), b, k));
}
}
}
Proof result[] = new Proof[proofs.size()];
proofs.toArray(result);
return result;
}
In this problem, you will complete several classes involving boxes, locks, keys and secrets. Follow the...
In this problem, you will complete several classes involving boxes, locks, keys and secrets. Follow the specifications in the starter files for the classes. You can run the javadoc program to generate the API (see Tutorial 2) for the classes. A box has a secret inside it (and maybe a key!) and can be locked. In order to open a box, you need the right key to unlock the lock. Secrets.java will be a program that takes an array of...
Write a program to pack boxes with blobs. Write two classes and a driver program. A Blob class implements the following interface. (Defines the following methods.) public interface BlobInterface { /** getWeight accessor method. @return the weight of the blob as a double */ public double getWeight(); /** toString method @return a String showing the weight of the Blob */ public String toString(); } A Blob must be between 1 and 4 pounds, with fractional weights allowed. A default constructor...
ArraysAndFiles.java and PartiallyFilledArray.java. They are shells that do not do anything. You will be adding code after the comments in the main method and using the javadoc documentation to implement the other methods. Task 1: Send array data to the screen In ArraysAndFiles.java, create a new method printOnScreen and compile it. In the main method of ArraysAndFiles.java, add the code to declare and initialize the array of Strings and call printOnScreen to print the array on the screen. Task 2:...
In Java You may add any classes or methods to the following as you see fit in order to complete the given tasks. Modify the LinkedList (or DoubleLinkedList) class and add a method append. append should take another LinkedList (DoubleLinkedList) as input and append that list to the end of this list. The append method should work by doing a few "arrow" adjustments on the boxes and it should not loop through the input list to add elements one at...
Programming Assignment #2 (Arrays) I. The Assignment This assignment is to take your Garage class from the previous assignment and modify it so that it uses an array of Car objects as the principal data structure instead of an ArrayList-of-Car. This is an example of the OOP principle of information hiding as your Car and test classes will not have to be modified at all. Unless you broke encapsulationon the previous assignment, that is II. Specifications Specifications for all 3...
Set-Up · Create a new project in your Eclipse workspace named: Lab13 · In the src folder, create a package named: edu.ilstu · Import the following files from T:\it168\Labs\lab13. Note that the .txt file must be in the top level of your project, not inside your src folder. o Student.java o StudentList.java o students.txt Carefully examine the Student.java and StudentList.java files. You are going to complete the StudentList class (updating all necessary Javadoc comments), following the instruction in the code....
8.16 Ch 8, Part 1: XOR Cipher Write this program using Eclipse. Comment and style the code according to CS 200 Style Guide. Submit the source code files (.java) below. Make sure your source files are encoded in UTF-8. Some strange compiler errors are due to the text encoding not being correct. This program will implement a simple XOR cipher on an integer array, where the data to be encoded is XOR'd with a key. This idea is often used...
The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should be included in an interface.) Specify operations to create an empty bag that can hold up to 100...
C++ project we need to create a class for Book and Warehouse
using Book.h and Warehouse.h header files given. Then make a main
program using Book and Warehouse to read data from book.dat and
have functions to list and find book by isbn
Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...
Need some help on homework practice problems, Thank you in advance! Problem 1: Write a method, parallelSum(), that uses the fork-join framework to compute the sum of the elements of an array. Its skeleton as well as its Javadoc is provided in the file ParallelSum.java. Simple code for testing and timing your method is also provided in the main method. This problem is essentially the same as ParallelMax in structure. Therefore, follow the code for ParallelMax to complete ParallelSum. Problem...