package analyzer import "errors" // Analyzer processes Transactions and generates reports. type Analyzer struct { // The list of Transactions available to analyze. transactions Transactions } // Add adds unique transactions to Analyzer. func (anz *Analyzer) Add(transactions Transactions) int { anz.transactions = append(anz.transactions, transactions...) return len(transactions) } // TransactionCount is the number of unique Transactions. func (anz *Analyzer) TransactionCount() int { return len(anz.transactions) } // TransactionsAmount is the total amount of all the transactions. func (anz *Analyzer) TransactionsAmount() Amount { return anz.transactions.Sum() } // LargestTransaction is the single largest transaction, ranked by // the absolute value of the transaction amount. Returns an error if there // are no transactions. // // - Note: Large negative transactions are still large--it just means the // money moved the other direction. func (anz *Analyzer) LargestTransaction() (Transaction, error) { // TODO: Not implemented. return Transaction{}, errors.New("not implemented") } // ByCategory groups the transactions by category and returns a map of // category name to the list of transactions that are part of that category. func (anz *Analyzer) ByCategory() map[string]Transactions { // TODO: Not implemented. return nil } // BigSpenderReport generates our Big Spender Report. // // "Big spenders" are defined as those people who, in aggregate // across their transactions, have spent more than 2 standard // deviations above the mean spender. // // The method determines who they are and generates a well-formatted // report to call them out. func (anz *Analyzer) BigSpenderReport() string { report := ` Digits Big Spenders Report ------------------------------------------------------ Name Amount ------------------------------------------------------` // TODO: Not implemented. // TODO: As a reminder, we're looking for well-factored, well-organized // code. We encourage you to refactor, change, or add to any part // of the non-test code as you see fit! report += "" return report } // New creates a new Analyzer with an empty set of transactions func New() *Analyzer { return &Analyzer{transactions: Transactions{}} }