Exercises
Design an API for modeling combinational logic circuits consisting of logic gates so that the model can be used to compute the output value of the logic function it represents for the given input values.
The API has to support at least the following gates:
Write test functions for the following tasks:
(x1 AND x2) and verify that the result is false for x1 = false and x2 = true, and true for x1 = true and x2 = true.((x1 AND x2) OR x3) and verify that the result is false for x1 = false, x2 = true, and x3 = false, and that it is true for x1 = false, x2 = false, x3 = true.(x1 OR (NOT x1)) and verify that the result is true for all values of x1.Modify the boolean circuit into fuzzy circuit, so that it computes on floating point numbers in the range 0.0 to 1.0 represented as double values. To preserve backwards compatibility, the operations with booleans have to continue to work – false should be treated as 0.0 and true as 1.0.
The basic elements need to be modified to work with doubles as follows:
The API has to support single creation, i.e., it should be possible to create a single circuit which can be later evaluated using both boolean and double inputs.
Write test functions for the following tasks:
(x1 AND x2) OR (NOT x1) and verify that the circut evaluates to the following values:
false for x1 = true and x2 = false,true for x1 = false and x2 = true,1.0 for x1 = 0.0 and x2 = 1.0,0.625 for x1 = 0.5 and x2 = 0.5,x1 = 0.0 and x2 = 2.0.x1 AND x1.GTE(x1,x2) = 1.0 iff x1 >= x2 else 0.0 and ensure that a circuit representing (x1 AND NOT(x1)) GTE x1 evaluates to the following results:
0.0 for x1 = 0.5,0.0 for x1 = 1.0, and1.0 for x1 = 0.0.Design API (classes, functions, …) for Windows file path manipulations
What are the requirements?
* path composition from elements
* getting path components (drive, directories, filename, extension)
* conversion between relative and absolute path
Extension: port to Unix environment
Design API for writing CSVs.
What are the requirements?
Write code that uses your API (use GitLab snippets).
Write the actual API.
Design API for querying current system version (i.e. application needs to do platform-specific operation).
What are the requirements?
Write the API.
Design API for running and controlling external applications (popen).
What are the requirements?
Write code that uses your API.
Write the actual API.
Design API for a harness which can execute benchmarks and collect timing (and other information) related to benchmark execution.
What are the requirements?
Write code that uses your API.
Write the actual API.
Extend the harness to enable changing the output format, control the number of repetitions, and provide additional information related to benchmark execution.
What are the requirements?
Write code that uses your API.
Write the actual API.
Design API that would be provided by OS VFS layer to end-user applications.
What are the requirements?
What API would be required from the concrete file systems?
Write both APIs.
Design API for management of DNS records.
What are the requirements?
Write code that uses your API.
Write the actual API.
Design “middle” API to simplify writing REST API bindings.
NOT this level
class GitLab {
GitLab(...);
User getUserByEmail(String email);
...
}
NOR this level
Socket socket = new Socket(...);
PrintWriter out = new PrintWriter(socket.getOutputStream());
out.println("GET / HTTP/1.0");
...
Design “middle” API to simplify writing REST API bindings.
What are the requirements?
Write code that uses your API.
Write the actual API.