/** * FinchModelAbstract *

* Your FinchModel class must extends this abstract class. This class stores * the "master action list" that is represented by your program. The class * provides: *

    *
  1. A set of methods for manipulating the master action list. It is through * these methods that your FinchDisplay class will manipulate the action list. *
  2. A set of methods for interacting with the Finch. Note: your FinchDisplay * class WILL NOT touch the Finch directly. *
*

* Notes: *

    *
  1. You may need to introduce private helper methods (in particular, you have * already implemented some of these in previous projects and labs). *
  2. You should not have to introduce any other public methods. *
*

* * @author Andrew H. Fagg * */ import java.io.*; import finch.*; abstract public class FinchModelAbstract { /** * A reference to the Finch object */ protected Finch myFinch; /** * The master action list */ protected FinchActionList masterActionList; /** * Constructor * *

* @param myFinch A reference to the Finch object *

* Postconditions: *

    *
  1. The master action list is initialized with an empty list *
*/ public FinchModelAbstract(Finch myFinch){ this.myFinch = myFinch; this.masterActionList = new FinchActionList(); } /** * Accessor to the master action list. *

* @return The master action list. */ public FinchActionList getFinchActionList() { return(masterActionList); } /** * Return the subset of the master action list that matches strg * *

* * @param strg String key * @return An action list that contains only those entries of the * master action list that match the name specified by strg */ abstract public FinchActionList getFinchActionList(String strg); /** * Load a text file containing an action list. *

* *

* Postconditions: *

    *
  1. The master action list is modified (assuming no file errors) *
*

* * @param file The name of the file to load */ abstract public void loadText(File file); /** * Load an action list from a binary file. *

* *

* Postconditions: *

    *
  1. The master action list is modified (assuming no file errors) *
*

* * @param file The name of the file to load * @param loadType LOAD_FILE = replace the master list with the one loaded from the file, * UNION_FILE = combine the master list with the one loaded (removing duplicates), * INTERSECT_FILE = combine the master list with the one loaded (keeping only the same items) */ abstract public void loadBinary(File file, LoadType loadType); /** * Write the master action list to a binary file. *

* Postconditions: *

    *
  1. The specified file is created if it does not exist. If it * does exist, the file is replaced. *
* *

* @param file The name of the file to be written. */ abstract public void saveBinary(File file); /** * Delete the specified FinchAction from the master action list. * *

* Note: equality is defined by the equality of the reference * (hint: review the available LinkedList methods) * * *

* Postconditions: *

    *
  1. The master action list is modified. *
* *

* @param action A FinchAction to be deleted */ abstract public void delete(FinchAction action); /** * Add a FinchAction to the master action list * * @param action The FinchAction to be added to the master action list. * *

* Postconditions: *

    *
  1. If the action does not already exist in the master action list * (as defined by FinchAction.compareTo(), the list is modified by * adding this new element. *
  2. The master action list is sorted. *
*/ abstract public void add(FinchAction action); /** * Execute the master action list (or a subset of it). * * *

* Postconditions: *

    *
  1. The Finch executed the specified actions. *
* *

* @param name The action names to execute. If "all", then * execute all actions. * @param reverse If true, then execute the actions in reverse order. * Note that ordering is specified by FinchAction.compareTo() * @param scale The scale at which to execute the actions. * */ abstract public void execute(String name, boolean reverse, double scale); }