Hi, I'm trying to figure out how to make a class for this checkbook program that will create an ArrayList of checks and then add to the array and then shrink the array. The output code has to look as follows:
Output from CheckbookTest
Code:
*****Checkbook Register*****
*****End of Register******
*****Checkbook Register*****
Position 0
Check Number 1
Date: September 23, 2003
Payee: Verizon
Amount: 62.55
Memo: null
*****End of Register******
*****Checkbook Register*****
Position 0
Check Number 1
Date: September 23, 2003
Payee: Verizon
Amount: 62.55
Memo: null
Position 1
Check Number 2
Date: September 23, 2003
Payee: Visa
Amount: 54.32
Memo: null
*****End of Register******
*****Checkbook Register*****
Position 0
Check Number 1
Date: September 23, 2003
Payee: Verizon
Amount: 62.55
Memo: null
Position 1
Check Number 2
Date: September 23, 2003
Payee: Visa
Amount: 54.32
Memo: null
Position 2
Check Number 3
Date: September 23, 2003
Payee: WGBH
Amount: 100.0
Memo: Pledge
*****End of Register******
*****Checkbook Register*****
Position 0
Check Number 1
Date: September 23, 2003
Payee: Verizon
Amount: 62.55
Memo: null
Position 2
Check Number 3
Date: September 23, 2003
Payee: WGBH
Amount: 100.0
Memo: Pledge
*****End of Register******
There are 3 files, Check.java, Checkbook.java, and CheckbookTest.java..
I have to create Checkbook.java, so it will accept information from CheckbookTest.java, and follow a format defined by Check.java
If any one can help me i will appreciate it!! thnx
[ArchAngel added CODE tags and converted text from all capitals to regular case]
Firstly, please read your post again and see how I changed it.
If you've looked through this forum, you'll regularly see the "Nobody here will do your coursework for you, but we're more than happy to help you with any problems" speach that I think I've typed out about a million times.
SO....please post the code you're written so far, a good description of the problems you've been having and the ideas you have about how to solve this problem.
I did tell what i had problems with, and I did post my code, I dont know how else to explain it, im having trouble creating the arraylist for this program and to implement check.java and checkbooktest.java into checkbook.java..........
[ArchAngel converted text from all capitals to regular case]
No, you didn't. There isn't a single question in your post or any statement as to what is directly causing you a problem.
"and I did post my code"
No, you didn't. There isn't a single line of Java in your post. You only posted what output is expected by your assessor.
"I dont know how else to explain it, im having trouble creating the arraylist for this program"
OK...that's almost a question... "having trouble"...what does that mean? You have no idea how to create an ArrayList? You're getting a compiler error? You're getting a runtime error? Post the code that you're written and any error messages you're getting and then I might stand a chance of working out what you're doing wrong.
"and to implement check.java and checkbooktest.java into checkbook.java"
Yes, you've already said that's what you coursework is....but what EXACTLY is the problem you're having? What don't you know how to do?
I hate to go on about this, but it's equivalent to phoning a mechanic and saying "My car's broken" - it's not very helpful! It could be that the car's wheels are squeaking slightly OR it could be that the accelerator pedal is permenantly stuck down, smoke is coming out from under the bonnet and two wheels have fallen off! If you don't tell your mechanic what EXACTLY is happening he won't be able to give you any advice.
ok first off my code is i given in the zip file attached to my post,, second i said i do not know how to implement the check.java and the checkbootest.java files into checkbook.java. im not sure how to setup checkbook.java to use an arraylist that excepts the parameters from the other classes..... i dont know how else to explain it??????
> ok first off my code is i given in the zip file attached to my post
Well I must be blind, because I can't see it. *I* have attached some dummy code to this post - I can see that.
> second i said i do not know how to implement the check.java and the checkbootest.java files into checkbook.java.
This is the point - you're not explaining it. "I don't know how to write this program" is not an explanation of the specific problem you're having.
> im not sure how to setup checkbook.java to use an arraylist that excepts the parameters from the other classes..... i dont know how else to explain it??????
I'm assuming you meant to write "How do I create a class 'CheckBook.java' that contains an ArrayList of 'Check.java' objects?" This is a very specific question. The answer to which would be:
No probs:
Code:
public class CheckBook {
private List checkList;
public CheckBook() {
// Setup the list.
checkList = new ArrayList();
}
public void addCheck(Check newCheck) {
checkList.addElement(newCheck);
}
}
I suggest you read Sun's tutorials for a more complete understanding of Collections:
Bookmarks