13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

298Chapter 13JUnit: Automating Unit TestingExample 13.1 The bare b<strong>on</strong>es of our Account classpackage net.multitool.core;import net.multitool.util.*;import java.util.*;/*** The basic Account class for our budgeting example; this is the* first-cut "implementati<strong>on</strong>" where we have just transferred our* design into Java code. We can use this much to generate Javadocs* and also to begin our JUnit testing (design, test, code).*/public classAccount{private String name; // a name to identify this accountprivate User owner; // the user assigned to this accountprivate SAM<strong>on</strong>ey total; // total amt allocated to this accountprivate HashMap children; // the collecti<strong>on</strong> of subaccounts,// by nameprivate Account parent; // it has this account as a child/*** Create an account, with a pool of dollars to budget.* Use this c<strong>on</strong>structor to create the master account.* Use "createSub" to create children of this account.*/publicAccount(String name, User owner, String total){}/*** Create a new subaccount (i.e., child), given a name* and an amount. The child is c<strong>on</strong>nected to the parent.*/public AccountcreateSub(String name, String amt){return null; // so it compiles} // createChild} // class Account

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!