Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

For this assignment, you need to create a class, called bit, to represent one bit. You must internally (private) use an integer to represent the

For this assignment, you need to create a class, called bit, to represent one bit. You must internally (private) use an integer to represent the one bit; the valid values are 0 (off) and 1 (on).

You must fully implement this interface (source file is provided):

public interface IBit {

void set(int value); // sets the value of the bit

void toggle(); // changes the value from 0 to 1 or 1 to 0

void set(); // sets the bit to 1

void clear(); // sets the bit to 0

int getValue(); // returns the current value

bit and(bit other); // performs and on two bits and returns a new bit set to the result

bit or(bit other); // performs or on two bits and returns a new bit set to the result

bit xor(bit other); // performs xor on two bits and returns a new bit set to the result

bit not(); // performs not on the existing bit, returning the result as a new bit

@Override

String toString(); // returns 0 or 1

}

You must implement the logic for these operations you cannot use the logic (&, &&, |, ||) operators for these operations. You may use if or switch.

You must provide a file (bit_test.java) that has a method (void runTests()). Each method of bit must be tested in bit_test.java.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students explore these related Databases questions