Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Task 1

Create a new project in Eclipse called Assignment 1.

Within this project create a package called task01.

1/ Download the class Date (you must use this class - not the ones in the SDK) from Moodle and add it to task01. This class has not been commented. You are required to add appropriate comments to this class.

In your report, answer the following:

Provide a class diagram for this class.
Look up the class Calendar in the Java API. What methods of the Calendar class are being used in the Date class?
This will be a little research task. Write about half a page on "static fields and methods". Include in your response answers to the following. What is their purpose? How do they differ from "instance methods"? How are static methods invoked? Which of Calendar's fields are being accessed in the Date class? (Note - your answer to this MUST be written in your own words).

2/ Create a class called Address using the following class diagram as a guide.

Address

String street

String city

String postcode

String country

void display ( )

Your class should also include appropriate get and set methods. Furthermore, provide two constructors

A default constructor which assigns each instance variable a default value. For example, you might assign the String "" to street.
A constructor with three String parameters which assign values to each instance variable.

The method display ( ) should display this description. An example of an Address might be "12 Ballarat St" (street), "Bendigo" (city), "3353" (postcode), "Australia" (country). Thus the description might be

12 Ballarat St,

Bendigo, 3353

Australia

Ensure your class (and all classes that you author) are appropriately commented.

2/ Create a class called Person (class diagram below)

Person

String name

Address address

Date dob

String toString ()

The field, name, is the Person's first name (eg "Fred", "Sue", "Rajiv" etc). We'll only use first names for the sake of simplicity.

The field, address, is the Person's address (you've already created the Address class).

The field, dob, is the Person's date of birth. You must use the Date class you have downloaded from Moodle (not one supplied by the SDK).

Again include appropriate get and set methods. Furthermore include a default constructor and a constructor which will initialise the fields through parameters.

3/ Download the class Test01 from Moodle. This class contains the main method and some test code for the Address and Date classes. This testing is not exhaustive (it doesn't test each of the methods in these classes). However, you can use the testDate and testAddress methods to give yourself an idea of whether you are on the right track with these classes (you will have to do some uncommenting in the main method).

The testPerson method has no code in it as yet. Provide code in this method that will exhaustively test the following methods of your Person class

getDob
setAddress
toString

Task 2
Create a second package, called task02, within the project Assignment 1.

1/ Create a new class called SavingsAccount (class diagram follows)

SavingsAccount

String accountNumber

double balance

void deposit (double )

bool withdraw (double)

void display ( )

The field, accountNumber, is a unique identification number for each SavingsAccount object (eg "M1234").

The field, balance, is the amount of savings in that particular account. The balance is set to zero when a SavingsAccount object is created. The balance is never allowed to go below zero.

This object will require a getter and setter for accountNumber but not for balance.

It should have a single constructor which sets the accountNumber. We won't allow "unknown" account numbers. The balance will be set to zero in this constructor.

The method, deposit, will add the value in the parameter to the balance.

The method, withdraw, will succeed only if there are sufficient funds in the account. If there are, then balance is updated and true is returned , otherwise the balance remains unchanged and false is returned.

Supply an appropriate display ( ) methods.

2/ Create a new class called Customer that extends the Person from task01. Do not copy the class Person to the new package. Import it from the package.

Customer

Vector accounts

void addAccount (SavingsAccount)

bool deleteAccount (SavingsAccount)

bool findAccount (SavingsAccount)

void displayAllAccounts ( )

void display ( )

A Customer can have any number of accounts (including zero).

Customer requires the default constructor. It requires no get and set methods.

There are three methods to add, find and delete accounts. We will assume that addAccount always succeeds. However, the find and delete methods will fail if the account does not exist. Thus they will return true if the objects exist and false otherwise.

The method displayAllAccounts will loop through the Vector and display the details of each of the Customer's accounts.

The method display ( ) will display all of the customer's details (eg name, address etc) as well as the details of his/her accounts.

3/ Create a class called Bank (class diagram follows)

Bank

Vector customers

Address address

String name

void addCustomer ( Customer)

bool deleteCustomer (Customer )

bool findCustomer ( Customer)

void displayAllCustomers ( )

void display ( )

Provide get and set methods for address and name. Provide at least two constructors.

The Address class should be imported from task01 - it should not be copied into the task02 package.

The discussion for the methods is very similar to that of the Customer class and won't be repeated here.

4/ Download the Test02 class from Moodle. This class contains a test method for the Customer class. Provide exhaustive test code for both the SavingsAccount and Bank classes in the appropriate test methods. You will be marked on how thoughtful (careful) you are with your testing.

Task 3

Create a new package called Task03. Copy (don't import this time - you'll be making modifications to them) the classes Bank, SavingsAccount and Customer into this new package.

1/ Consider a class called CreditAccount with the following class diagram

CreditAccount

String accountNumber

double balance

double creditLimit

void deposit (double )

bool withdraw (double)

void display ( )

This is a second kind of account that a Customer can have. It differs from the SavingsAccount in that the Customer is allowed to have a creditLimit which means that his/her balance can be less than zero. If the creditLimit is $1000 then the customer can withdraw up to $1000 more than they have in their account. This will mean that the withdraw method will need to be implemented differently to SavingsAccount.

A Customer is allowed to have any number of accounts (either Savings or Credit). We can add these objects to the accounts Vector in the Customer class. However, we will find a lot of problems when we try to loop through them and perform operations them.

In your report, discuss an abstract class called Account which both SavingsAccount and CreditAccount will extend. Explain how such a class might be used to solve the problems outlined about. Discuss the

Instance variables
Concrete methods
Abstract methods

which would belong to the Account class.

Finally, discuss the changes that you will need to make to the Customer and Bank classes to make the new arrangement work correctly.

2/ Implement the changes you have outlined in part 1. (Note you must use inheritance properties. Do not use any of the Reflection classes to solve these problems).

3/ Add an abstract method to Account called interest ( ). This method will need to be implemented differently in the subclasses.

In SavingsAccount - add 1% to the balance.
In CreditAccount - if the balance is positive add 2%. If negative charge 10% as interest.

In the Bank class add a method called updateInterest ( ) which will loop through each of the Customer objects in its customers Vector. For each customer, loop through all accounts and update the interest appropriately.

4/ Create a Test03 class with appropriate test methods. You will be marked upon how thoughtful (and careful) you are with your testing.

Java, Programming

  • Category:- Java
  • Reference No.:- M9522634

Have any Question?


Related Questions in Java

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As