subject

Main topics: Inheritance Polymorphism Abstract Classes Program Specification:
Being able to program with numbers that do not (in theory) have a maximum value is a necessity in many applications of computer science. You are going to write a series of classes to get started on this task. Your final class will allow you to represent and at least add Binary numbers of arbitrary length.
public abstract AbstractBit: You are to write (implement) this class exactly as dictated by the following list of class members.
private boolean bit;
public abstract AbstractBit clone();
public abstract AbstractBit addBits(AbstractBit guest);
public abstract AbstractBit addBits(AbstractBit guest1, AbstractBit guest2);
public abstract AbstractBit carryBit(AbstractBit guest);
public abstract AbstractBit carryBit(AbstractBit guest1, AbstractBit guest2);
protected void setBit(boolean value)
public boolean getBit()
public AbstractBit()
public AbstractBit(boolean value)
public AbstractBit(AbstractBit guest)
public boolean equals(AbstractBit guest)
public String toString()
public BinaryBit extends AbstractBit: You are to write (implement) this class exactly as dictated by the following list of class members.
public static final BinaryBit zero = new BinaryBit(false);
public static final BinaryBit one = new BinaryBit(true);
public BinaryBit()
public BinaryBit(boolean bit)
public BinaryBit(int bit)
public BinaryBit(BinaryBit guest)
public BinaryBit clone()
public boolean equals(BinaryBit guest)
public String toString()
public AbstractBit addBits(AbstractBit guest)
public AbstractBit addBits(AbstractBit guest1, AbstractBit guest2)
public AbstractBit carryBit(AbstractBit guest)
public AbstractBit carryBit(AbstractBit guest1, AbstractBit guest2)
public BitString: You are to write (implement) this class exactly as dictated by the following list of class members.
private ArrayList bitString;
private void setAbstractBitList(ArrayList bitList)
protected ArrayList getAbstractBitList()
public void addBit(AbstractBit bit)
public AbstractBit bitAt(int loc)
public BitString()
protected BitString(ArrayList bitList)
public BitString(BitString guest)
public boolean isEmpty()
public int length()
public BitString clone()
public boolean equals(BitString guest)
public String toString()
public Binary extends BitString: You are to write (implement) this class exactly as dictated by the following list of class members.
public Binary()
public Binary(long val)
public Binary(BitString guest)
public Binary(Binary guest)
public Binary clone()
private void encode(long val)
public Binary addition(Binary guest)
Your Class must also work with the following Driver Class public Driver:
public class Driver { public static void main(String[] args) {
Binary n1 = new Binary();
Binary n2 = new Binary(10);
Binary n3 = n2.clone();
System. out. println("n1 = " + n1);
System. out. println("n1.length() = " + n1.length());
System. out. println("n2 = " + n2);
System. out. println("n2.length() = " + n2.length());
System. out. println("n3 = " + n3);
System. out. println("n3.length() = " + n3.length());
System. out. println("n3.bitAt(1) = " + n3.bitAt(1));
System. out. println();
System. out. println("n1 equals n1 ? " + n1.equals(n1));
System. out. println("n1 equals n2 ? " + n1.equals(n2));
System. out. println("n2 equals n3 ? " + n2.equals(n3));
System. out. println();
Binary n4 = n2.addition(n2);
System. out. println("n4 = " + n4);
for (int i = 0; i <= 10; ++i) { n4 = n4.addition(n4); n4 = n4.addition(n2);
System. out. println("n4 = " + n4); } } }
And produce the following output exactly:
n1 = 0 n1.length() = 1
n2 = 1010
n2.length() = 4
n3 = 1010
n3.length() = 4
n3.bitAt(1) = 1
n1 equals n1 ? true
n1 equals n2 ? false
n2 equals n3 ? true
n4 = 10100
n4 = 110010
n4 = 1101110
n4 = 11100110
n4 = 111010110
n4 = 1110110110
n4 = 11101110110
n4 = 111011110110
n4 = 1110111110110
n4 = 11101111110110
n4 = 111011111110110
n4 = 1110111111110110

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 13:30
To remove a header or footer from a document you can open the header and footer and manually delete the content true or false
Answers: 1
question
Computers and Technology, 23.06.2019 01:40
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
question
Computers and Technology, 23.06.2019 04:31
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
question
Computers and Technology, 23.06.2019 09:50
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
You know the right answer?
Main topics: Inheritance Polymorphism Abstract Classes Program Specification:
Being able to...
Questions
question
Mathematics, 05.05.2020 15:43
question
Mathematics, 05.05.2020 15:43
Questions on the website: 13722361