Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Proiect Description Create a simple binary class that performs operations on binary numbers stored as a one dimensional integer array. Leaming Objectives How to create,

Proiect Description
Create a simple binary class that performs operations on binary numbers stored as a one dimensional integer array.
Leaming Objectives
How to create, modify and access one-dimensional arrays in Java
How multiplying, dividing and negative numbers work in binary/computers
What it means to and/or/not/rotate left or right a number
Reinforce creating a class from scratch - Implement an Interface
Assignment
Create a class that manipulates binary numbers
Constructors:
Binary()// default constructor that creates the array
Binary (Binary anyBin)//constructor that copies a given Binary and creates a Binary object Binary(String bitString)//constructor that converts a String of 1 s and 0s to a Binary object Binary(int num)//constructor that converts a decimal to an Binary object
Binary(int][)// constructor that uses an int[ to create a Binary object Bits
Methods:
public String toString()// Converts a Binary object to a String
Binary not()// Returns a new Binary object that is the logical "not" of the Binary object
Binary or( Binary rhs)// Returns a new Binary object that is "or"ed with the Binary object
Binary and(Binary rhs)// Returns a new Binary object that is "and"ed with the Binary object
Binary add(Binary rhs)// Returns a new Binary object which is the sum of the Binary object and the rhs
Binary twosComplement()// Returns a new Binary object that is the twosComplement of the Binary object
Binary int2bin(int num)// Returns a new Binary object that is the decimal number converted to binary
Binary rotateRight()// Returns a new Binary objhct that is a copy of the Binary object rotated right by one digit
Binary rotateLeft()// Returns a new Binary object that is a copy of the Binary object rotated left by one digit
int bin2int()// Returns an int that is the decimal value of the Binary object static void test()// tests the methods of the Binary class
image text in transcribed

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

Step: 3

blur-text-image

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

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions