Question: This assignment builds on the previous assignment (use the code from this link https://www.chegg.com/homework-help/questions-and-answers/assignment-need-create-class-called-bit-represent-one-bit-must-internally-private-use-inte-q67886194?trackid=w7Q_HgzB). For the machine that we are simulating, we will be using

This assignment builds on the previous assignment (use the code from this link https://www.chegg.com/homework-help/questions-and-answers/assignment-need-create-class-called-bit-represent-one-bit-must-internally-private-use-inte-q67886194?trackid=w7Q_HgzB). For the machine that we are simulating, we will be using a 32-bit value for both addresses and values.

You must fully implement this interface (source file is provided). You must make a new class called Longword that does not inherit from anything. You must create a collection (array is best) of Bit (from assignment 1) and use that for storage. You may not use any other storage mechanism.

public interface ILongword {

bit getBit(int i); // Get bit i

void setBit(int i, bit value); // set bit i's value

longword and(longword other); // and two longwords, returning a third

longword or(longword other); // or two longwords, returning a third

longword xor(longword other);// xor two longwords, returning a third

longword not(); // negate this longword, creating another

longword rightShift(int amount); // rightshift this longword by amount bits, creating a new longword

longword leftShift(int amount);// leftshift this longword by amount bits, creating a new longword

@Override

String toString(); // returns a comma separated string of 0's and 1's: "0,0,0,0,0 (etcetera)" for example

long getUnsigned(); // returns the value of this longword as a long

int getSigned(); // returns the value of this longword as an int

void copy(longword other); // copies the values of the bits from another longword into this one

void set(int value); // set the value of the bits of this longword (used for tests)

}

You may use loops to implement the same operation done on each bit. You must use the operations from bit (and, or, not, xor, getBit, set) where appropriate. You must validate inputs where appropriate.

You must provide a test file (longword_test.java) that implements void runTests() and call it from your main, along with your bit_test.runTests(). As with the bit test, these tests must be independent of each other and there must be reasonable coverage. You cannot reasonably test all 4 billion possible longwords, but you can test a few representative samples.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!