Midterm Exam
Due Sunday February 22 by 11:30 PM

Overview

This is take-home midterm exam consisting of two parts: an online D2L quiz and a part with programming tasks. You are required complete this midterm individually, but you may use the book and notes.

Since the final exam will be a traditional closed-book, closed-notes exam on paper, you are encouraged to make a similar first-attempt on this midterm, which includes writing your code on paper. Then, as needed, you can refer to notes and books. Code can then be typed in with Eclipse to test it and modify as needed.

The due date is final. Late submissions will not be accepted. Multiple submissions for Part B are fine---I will grade the last submission.

Part A

Part A is a D2L quiz. As with the first quiz, you have two attempts and your best score will be taken. Part A is worth 15 points (1.5 points per question).

Part B

This part has programming tasks based on the ArrayAccount class and the LLAcount class. These are classes that represent a simple collection of transaction objects, each consisting of an ID, a type (credit or debit) and an amount (always stored as an integer). Their methods produce the same functionality but using different data structures. Both classes make use of the Transaction class.

The three classes (ArrayAccount, LLAcount and Transaction) are provided for you in the midterm package, which you can import into Eclipse.

Part B is worth 25 points. The points for the individual methods are noted in parentheses with each method description.

ArrayAccount

The ArrayAccount class implements the Account with an array. The class definition, method parameters, method names, instance variables and most method implementations are provided.

You need to implement the following:

  • append (4) --- add a Transaction object to the end of the account
  • balance (4) --- return the current balance, where amounts of "credit" types are positive and amounts of "debit" types are negative
  • check (5) --- return true if all transactions have a unique id and are in ascending order, false otherwise

The method defintions are further specified as comments in the code. The number of points indicate how much the implementation is worth and roughly corresponds to the complexity of the implementation.

LLAccount

This LLAccount class implements the Account with a linked list. The class definition, method parameters, method names, instance variables and most method implementations are provided.

You need to implement the following:

  • first (2) --- return the first transaction object in the account without changing the account (assume that the account has at least one transaction)
  • count (4) --- return the number of transactions in the account
  • insert (6) --- insert the transaction so that its id is greater than the previous element and less than the next element; you may assume that the id is unique and that the transactions are already in ascending order

Additional requirements:

  • The instance variables should not change. The current declarations are adequate for completing Part B.
  • The method names or parameters should not change.
  • To submit, zip up the source code as the midterm package to the D2L dropbox.
  • Your code must compile. If you have code that is causing problems, you may comment it out. You may still receive partial credit for it.

Some advice:

  • Studying the implemented methods may be useful for completing the unimplemented methods.
  • The methods in both classes should have the same functionality. If you are not sure what a method should do, you can study the method in the other class, which is implemented.
  • Clarification questions may be submitted to the D2L discussion board, but your code should not be posted there.
  • The code in the main methods provide good tests for the code, but you may add additional code.
  • Partial credit will be awarded for methods that have some conceptually correct code (even if commented out).
  • Start early and take an incremental approach!