Question: **I've attached images of the code and example output below which include the Check class & the print() method in that class, example format of

**I've attached images of the code and example output below which include the Check class & the print() method in that class, example format of Junit tests & Printable interface** TIA!

For the public void print() method in the image below:

create TWO Junit tests (in similar format to testIsAccountValidPASS() & testISAccountValidFAIL() examples in images.) for this print() method.

Check Class*************************

**I've attached images of the code and example output below which include

public class Check implements Printable {

// attributes

private String accountID;

private String bankID;

private int number;

private String payee;

private double amount;

private String date;

// constructors

public Check() {

}

/**

* @param accountID

* @param bankID

* @param number

* @param payee

* @param amount

* @param date

*/

public Check(String accountID, String bankID, int number, String payee, double amount, String date) {

this.setAccountID(accountID);

this.setBankID(bankID);

this.setNumber(number);

this.setPayee(payee);

this.setAmount(amount);

this.setDate(date);

}

*********************************************************

print() Method in check class that needs Junit tests*******************************************************

the Check class & the print() method in that class, example format

@Override

public void print() {

String fileContent =

" check# "+this.number+" "+

" date: " +this.date+" "+

"payee: "+this.payee+" "+"$ "+this.amount+" "+

"accountID:"+this.accountID+" bankID:"+this.bankID+" "+

"----------------------------------------------------";

FileWriter fileWriter = null;

try {

fileWriter = new FileWriter("CheckFile.txt");

} catch (IOException exception) {

System.out.println("An error occurred.");

exception.printStackTrace();

}

PrintWriter printWriter = new PrintWriter(fileWriter);

printWriter.print(fileContent);

printWriter.close();

}

*******************************************************************

VALIDATION example for use in Junit

public boolean isAccountIdValid() {

boolean retValue = true;

if(accountID == null) {

retValue = false;

}

return retValue;

}

**********************************************

EXAMPLE Junit FORMAT PASS/FAIL

@Test

void testIsPrintValidPASS() {

//test code

}

*********************************************************

@Test

void testIsPrintValidFAIL() {

//test code

}

of Junit tests & Printable interface** TIA! For the public void print()

@Test

void testIsAccountIdValidPASS() {

Check check = new Check();

check.setAccountID("myAccount8");

boolean expectedResult = true;

boolean actualResult = check.isAccountIdValid();

assertEquals(expectedResult,actualResult);

}

@Test

void testIsAccountIdValidFAIL() {

Check check = new Check();

check.setAccountID(null);

boolean expectedResult = false;

boolean actualResult = check.isAccountIdValid();

assertEquals(expectedResult,actualResult);

}

Not sure if this is needed but including Printable interface****************

method in the image below: create TWO Junit tests (in similar format

public interface Printable {

public void print();

}

16 La public class Check implements Printable { // attributes private String accountID; private String bankID; private int number; private String payee; private double amount; private String date; 24 // constructors public Check() { 250 26 27 280 29 /** * @param accountID * @param bankID * @param number * @param payee * @param amount * @param date 35 */ 360 37 public Check(String accountID, String bankID, int number, String payee, double amount, String date) { this.setAccountID(accountID); this.setBankID(bankID); this.setNumber(number); this.setPayee (payee); this.setAmount (amount this.setDate(date); @Override public void print() { String fileContent = 'check# "+this. number+" "+ date: " +this.date+" "+ "payee: "+this.payee+" "+"$ "+this.amount+" "+ "accountID:"+this accountID+" bankID:"+this.bankID+" " + ------"; FileWriter fileWriter = null; try { fileWriter = new FileWriter("CheckFile. txt"); '} catch (IOException exception) { System.out.println("An error occurred.") exception.printStackTrace(); PrintWriter printwriter = new PrintWriter(fileWriter); printWriter.print(fileContent); printwriter.close(); public boolean isPrintvalid() { boolean retValue = true; if(????) { retValue = false; return retValue; // Validations public boolean isAccountIdValid() { boolean retValue = true; if(accountID == null) { retValue = false; return retValue; @Test void testIsAccountIdValidPASS() { Check check = new Check check.setAccountID("myAccount8") boolean expected Result = true; boolean actualResult = check.isAccountIdValid(); assertEquals(expectedResult, actualResult); @Test void testIsAccountIdValidFAILO { Check check = new Check check.setAccountID(nullo boolean expected Result = false; boolean actualResult = check.isAccountIdValid(); assertEquals(expectedResult, actualResult); public interface Printable { public void print(); 16 La public class Check implements Printable { // attributes private String accountID; private String bankID; private int number; private String payee; private double amount; private String date; 24 // constructors public Check() { 250 26 27 280 29 /** * @param accountID * @param bankID * @param number * @param payee * @param amount * @param date 35 */ 360 37 public Check(String accountID, String bankID, int number, String payee, double amount, String date) { this.setAccountID(accountID); this.setBankID(bankID); this.setNumber(number); this.setPayee (payee); this.setAmount (amount this.setDate(date); @Override public void print() { String fileContent = 'check# "+this. number+" "+ date: " +this.date+" "+ "payee: "+this.payee+" "+"$ "+this.amount+" "+ "accountID:"+this accountID+" bankID:"+this.bankID+" " + ------"; FileWriter fileWriter = null; try { fileWriter = new FileWriter("CheckFile. txt"); '} catch (IOException exception) { System.out.println("An error occurred.") exception.printStackTrace(); PrintWriter printwriter = new PrintWriter(fileWriter); printWriter.print(fileContent); printwriter.close(); public boolean isPrintvalid() { boolean retValue = true; if(????) { retValue = false; return retValue; // Validations public boolean isAccountIdValid() { boolean retValue = true; if(accountID == null) { retValue = false; return retValue; @Test void testIsAccountIdValidPASS() { Check check = new Check check.setAccountID("myAccount8") boolean expected Result = true; boolean actualResult = check.isAccountIdValid(); assertEquals(expectedResult, actualResult); @Test void testIsAccountIdValidFAILO { Check check = new Check check.setAccountID(nullo boolean expected Result = false; boolean actualResult = check.isAccountIdValid(); assertEquals(expectedResult, actualResult); public interface Printable { public void print()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!