QuestionQuestion

Instructions for week #5:

This week’s programming assignment is to add the printable interface and set up the appropriate classes on the Class diagram to use it.

When implementing the interface set up printing to a text file.

For the entry (a register entry) create a file that gets appended to every time add a new entry.

For the check class create a new file for each check - these files will be printed on checks.

For ease at the moment, call the print method from your command line user interface

You will be implementing the interface for the Entry and Check classes.

As with the previous assignments, include unit testing, proper exception/error handling, documentation and encapsulation.

You do not need to test the printable interface or it implementations. Instead you can create screenshots of the output in your write up.

For the write-up this week you will be writing a lambda expressions, in addition to the traditional write up.

Find a Java Lambda expression online or in a textbook other than the class textbook.

Explain how it works and why it would be beneficial to use it, rather than writing out an entire class.

Make sure you reference the source where you found the lambda expression.

The expression you choose to analyze need not have anything to do with our current problem scenario.

Purpose: The assignment will allow you to show your knowledge and understanding of implementing interfaces and lambda expressions.

Extra Credit: For an additional 10% of the grade (8.5 points) write your own lambda expression.

In the code and in your write up make sure you label your lambda expression clearly.

In the write up demonstrate with accompanying screenshots how your lambda expression works

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Stream;
/**
* The Class Check.
*/
public class Check implements Printable{

    /** The account ID. */
    private String accountID;
   
    /** The bank ID. */
    private String bankID;
   
    /** The user ID. */
    private String userID;
   
    /** The number. */
    private int number;
   
    /** The payee. */
    private String payee;


    /** The amount. */
    private double amount;
   
    /** The date. */
    private Date date;   

    /**
    * Instantiates a new check.
    */
    public Check() {

}
   
   

/**
* Gets the user ID.
*
* @return the userID
*/
public String getUserID() {
return userID;
}


/**
* Sets the user ID.
*
* @param userID the userID to set
*/
public void setUserID(String userID) {
this.userID = userID;
}



/**
* Gets the account ID.
*
* @return the account ID
*/
// Providing getters and setters to access private members
    public String getAccountID() {
       return accountID;
    }

    /**
    * Sets the account ID.
    *
    * @param accountID the new account ID
    */
    public void setAccountID(String accountID) {
       this.accountID = accountID;
    }

    /**
    * Gets the bank ID.
    *
    * @return the bank ID
    */
    public String getBankID() {
       return bankID;
    }

    /**
    * Sets the bank ID.
    *
    * @param bankID the new bank ID
    */
    public void setBankID(String bankID) {
       this.bankID = bankID;
    }

    /**
    * Gets the number.
    *
    * @return the number
    */
    public int getNumber() {
       return number;
    }

    /**
    * Sets the number.
    *
    * @param number the new number
    */
    public void setNumber(int number) {
       this.number = number;
    }

    /**
    * Gets the payee.
    *
    * @return the payee
    */
    public String getPayee() {
       return payee;
    }

    /**
    * Sets the payee.
    *
    * @param payee the new payee
    */
    public void setPayee(String payee) {
       this.payee = payee;
    }

    /**
    * Gets the amount.
    *
    * @return the amount
    */
    public double getAmount() {
       return amount;
    }

    /**
    * Sets the amount.
    *
    * @param amount the new amount
    */
    public void setAmount(double amount) {
       this.amount = amount;
    }

    /**
    * Gets the date.
    *
    * @return the date
    */
    public Date getDate() {
       return date;
    }

    /**
    * Sets the date.
    *
    * @param date the new date
    */
    public void setDate(Date date) {
       this.date = date;
    }
   

    /* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Check [accountID=" + accountID + ", bankID=" + bankID + ", number=" + number + ", payee=" + payee
+ ", amount=" + amount + ", date=" + date + "]";
}

/**
* Gets the check info.
*
* @return the check info
*/
public String getCheckInfo(){
       return "" + number + ", " + payee + ", " + amount + ", " + date.toString();
    }

/**
* Validate check number.
*
* @return true, if successful
*/
public boolean validateCheckNumber() {
boolean retValue = true;
if(number < 100 || number > 1000) {
retValue = false;
}
return retValue;
}



/**
* Validate amount.
*
* @return true, if successful
*/
public boolean validateAmount() {
boolean retValue = true;
if(amount < 0) {
retValue = false;
}
return retValue;
}



@Override
public void print(String fileName) throws Exception{
try {
FileWriter fw = new FileWriter(fileName, true);
List<String> rows = Arrays.asList(getCheckInfo());
Stream<S...

By purchasing this solution you'll be able to access the following files:
Project1.zip.

$13.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats