Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Block implements Transaction{ private int transactionId; private String firstName; private String lastName; private String description; private long timeStampMillis; private long hashNextBlock; private static

public class Block implements Transaction{

private int transactionId;

private String firstName;

private String lastName;

private String description;

private long timeStampMillis;

private long hashNextBlock;

private static int numBlocks = 0;

/**

* Constructor for a Block

* @param id the transaction id

* @param first the customer first name

* @param last the customer last name

* @param description the transaction description

* Calls System's currentTimeMillis() method

* to assign the timeStampMillis

* Increases the numBlocks

*/

public Block(int id, String first, String last, String description) {

}

/**

* Returns the current number of blocks

* @return the number of blocks

*/

public static int getNumBlocks() {

return numBlocks;

}

/**

* Calculates the hash for the next

* block

* @param id the next block's id

* @param firstName the customer first

* name for the next block

* @param lastName the customer last

* name of the next block

*/

public void computeHash(int id, String firstName, String lastName) {

String name = firstName + lastName;

int sum = 0;

for (int i = 0; i < name.length(); i++) {

sum += name.charAt(i);

}

hashNextBlock = sum * 10000 + id;

}

/**

* toString for the Block class

* @return a String of Block object

*

*/

@Override public String toString() {

return " "

}

}

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

Students also viewed these Databases questions

Question

Identify the different methods employed in the selection process.

Answered: 1 week ago

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago