Extract similar fields from Transaction and NFT classes
This commit is contained in:
parent
a6728214b2
commit
b791bef037
|
@ -0,0 +1,9 @@
|
|||
package pl.mikorosa.dziecoin;
|
||||
|
||||
public abstract class BlockData {
|
||||
protected String owner;
|
||||
|
||||
public String getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package pl.mikorosa.dziecoin;
|
||||
|
||||
public class NFT {
|
||||
public class NFT extends BlockData {
|
||||
private String contract;
|
||||
private String owner;
|
||||
private String data;
|
||||
|
||||
public NFT(String owner, String data) {
|
||||
|
@ -23,10 +22,6 @@ public class NFT {
|
|||
return contract;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package pl.mikorosa.dziecoin;
|
||||
|
||||
public class Transaction {
|
||||
private String sender;
|
||||
public class Transaction extends BlockData {
|
||||
private String recipient;
|
||||
private int amount;
|
||||
|
||||
public Transaction(String sender, String recipient, int amount) {
|
||||
this.sender = sender;
|
||||
this.owner = sender;
|
||||
this.recipient = recipient;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
return owner;
|
||||
}
|
||||
|
||||
public String getRecipient() {
|
||||
|
@ -26,7 +25,7 @@ public class Transaction {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "Transaction{" +
|
||||
"sender='" + sender + '\'' +
|
||||
"sender='" + owner + '\'' +
|
||||
", recipient='" + recipient + '\'' +
|
||||
", amount=" + amount +
|
||||
'}';
|
||||
|
|
Loading…
Reference in New Issue