Git – java

You will need to do the work on a computer with the following installed:
• JDK 8 (either OpenJDK or the Oracle distribution)
• Git (any recent version)
• The Ant build tool We assume the use of a command line and standard text editor;
you will need to adjust the instructions below as appropriate if you decide to use an IDE.

Preparation
1. unzip the directory.
2. cd into the cw directory and use git init to create a Git repository. Then use the git add and git commit commands to add the files to the repository.
3. Take a moment to study the files. Note the presence of two .java files in subdirectories of src. You will need to implement your classes in these files. Note also the file build.xml—an Ant build script that will help you to compile, test and even submit your code.

Task
1. For 8 marks, edit BankAccount.java and add the following to the BankAccount class:
• Instance variables to represent account ID (a string), name of account holder (a string) and current balance of the account (an integer)
• Getter methods for each of these instance variables
• A constructor that accepts an account ID and account holder name as parameters, uses these values to initialise the corresponding instance variables, then initialises balance to zero

Use one or two commits to make these changes. Compile the class to check your coding. The best way of doing this is via the command ant compile.

2. For 12 marks, add the following methods to the class, doing a commit after each method is completed:
toString to return a string representation of the account that looks similar to this example:

Account 001754, John Smith, balance 1250

deposit to deposit a sum of money (given as an integer parameter) into the account withdraw to withdraw a sum of money (given as an integer parameter) from the account transfer to transfer a sum of money (given as an integer parameter) to another Bank Account (given as another parameter of the method)

Your deposit method should throw an exception if the sum to be deposited is negative. Your withdraw method should throw an exception if the sum is negative or withdrawing that sum would take the balance below zero. You can use the standard Illegal Argument Exception class in each case.

Remember to use ant compile frequently to check that your code compiles.

3. For 3 marks, write sensible doc comments for the class itself and for its methods. Check that your doc comments make sense by generating HTML for your class. You can do this using the comand ant doc. Documentation will be generated in a sub-directory called doc. Open the file index.html in a browser to check the generated HTML.

If you need advice on how to write doc comments, see http://bit.ly/jdochowto

4. For 8 marks, edit Bank Account Test.java and add an appropriate set of JUnit tests for the Bank Account class. As you add each test, run the unit tests using the command ant test.

5 marks will be awarded for using version control sensibly during development of the class—for example, committing code after each method is implemented and using sensible commit messages.

Successful compilation and execution of the tests will earn 2 marks.

A further 2 marks will be awarded for adopting a neat and consistent coding style.

Submit the entire cw directory and all its contents as a single Zip archive. You can generate this easily on the command line by entering the command ant zip.

Unlike most other websites we deliver what we promise;

  • Our Support Staff are online 24/7
  • Our Writers are available 24/7
  • Most Urgent order is delivered with 6 Hrs
  • 100% Original Assignment Plagiarism report can be sent to you upon request.

GET 15 % DISCOUNT TODAY use the discount code PAPER15 at the order form.

Type of paper Academic level Subject area
Number of pages Paper urgency Cost per page:
 Total: