Get your CodeRanch badge!*
The moose likes Beginning Java and the fly likes Vectors & Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vectors & Array " Watch "Vectors & Array " New topic
Author

Vectors & Array

sheppards brown
Greenhorn

Joined: May 21, 2006
Posts: 2
Guys Im lost...cld someone do a rundown with me? im quite lost from pt.2 onwards...thanks...



You are required to take an existing program for managing a credit card and to enhance the functionality of
the program. The existing program is available for download on the course web page. The files you will
download will be:
� README � a text file describing these files
� CardInterface.java � the interface to be used for the credit card classes
� CreditCard.java � an initial implementation of CardInterface
� Calendar.java � a skeleton to be used for the Calendar class (see below)
� Test.java � a test program for the CreditCard class
� Test.out � the expected output from the Test program
� AuditedTest.out � the expected output from the AuditedTest program (see below)
� FeesTest.out � the expected output from the FeesTest program (see below)
The steps you should follow for this assignment are listed below. NOTE for this assignment, steps 1 to 6 are
required, steps 7 to 9 are optional, i.e. you don�t need to implement and submit these classes and they will
not be graded, but it is a good exercise for you to brush up on your Java programming skills.
1. Compile and run the Test.java program and make sure its output corresponds with the file Test.out.
Under Unix you can redirect the output to a temporary file using the command java Test > tmp
and then check for differences using the command diff tmp Test.out.
2. Write a Java class called Calendar which fills in the skeleton provided in the file Calendar.java. In
other words, it has a static Date method called getDate() to return the current date, and a static void
method called tock(int days) to advance the date by the specified number of days. This means that the
class will need to have a static variable of type Date (initialised to the 1st January 2005),
(Note that you are asked to use the class java.util.Date which the compiler will flag as deprecated. This
means that the class should not be used for production software because it is not guaranteed to be
retained in later revisions of Java. The specific problem is that the class Date is not amenable to
internationalization. Therefore, other Calendar classes have been introduced. Unfortunately, the
generalization embodied in these Calendar classes makes them excessively complex for the purposes of
this simple assignment, and hence the advice to use the class Date.)
3. Write a Java class called Transaction (in a file called Transaction.java), which records the information
about a credit card transaction, i.e. the date, the kind of transaction (which is one of the strings �new�,
�credit�, �debit� or �fee�), and the amount.
4. Write a Java class called AuditedCard (in a file called AuditedCard.java), which extends the class
CreditCard so that it still implements the same interface, but now records the transactions performed on
the card. (Note that creating a card and making a charge or a payment are all considered to be
transactions, but getting the balance is not.) You should use a Java ArrayList or a Vector to record the
transactions. The method void print( ) should now print all the transactions for the card in addition to
the account details and current balance.
5. Write a Java class called AuditedTest (in a file called AuditedTest.java), which is the same as Test
except that it creates instances of class AuditedCard rather than CreditCard, and advances the calendar
by 7 days after every transaction (on every card), and prints the transactions for each card following all
the payments. The proposed output is given in file AuditedTest.out. (Note that the format for the date
is obtained using the toString method for class Date.)
6. You should also develop your own test programs for class AuditedCard. You should use the same
naming convention as above, i.e. xyzTest.java for the test program xyzTest.out for the expected output.
These files should be documented in the README file.
7. Write a Java class called FeesCard (in a file called FeesCard.java), which extends the class
AuditedCard so that it implements the same interface, but now charges fees for the credit card. At the
first day of each month, you should charge interest at the rate of 2% of the outstanding balance. The
easiest way to do this is that every time you receive a method call for a credit card (including a call to
getBalance and print), you should add the charges since the last transaction. The fees should always be
rounded to the nearest cent.
8. Write a Java class called FeesTest (in a file called FeesTest.java), which is the same as AuditedTest
except that it creates instances of class FeesCard rather than AuditedCard. The proposed output is given
in file FeesTest.out.
9. You should also develop your own test programs for the class FeesCard. You should use the same
naming convention as above, i.e. xyzTest.java for the test program xyzTest.out for the expected output.
These files should be documented in the README file.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
posting your assignment is never a good idea - it (generally) indicates the poster
is after a hand-out, which is not how these forums work.

if you have a specific problem and post your attempt at a solution, along with
what you expect vs what you get, you'll find just about everyone willing to
give you a nudge in the right direction.

break the assignment down into it's individual parts, work on one at a time,
and if you get stuck, post per the previous paragraph.
sheppards brown
Greenhorn

Joined: May 21, 2006
Posts: 2
okie sure...perhaps someone could explain to me how to go about pt.2 and 3?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> perhaps someone could explain to me how to go about pt.2 and 3?

perhaps you should start here

http://java.sun.com/docs/books/tutorial/java/concepts/interface.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vectors & Array
 
Similar Threads
Quick question about the date class
DreamCar: interface with the inventory system dilemma
New to Java - i need help please!
Silly Question on OOD
Please help!!