Go Back   nV News Forums > Software Forums > Software Development

Newegg Daily Deals

Reply
 
Thread Tools
Old 01-25-07, 05:12 PM   #1
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Sigh, Java HW Help

So basically I have to design a program that carries out banking operations on a customers' account.

Now what I need to do is create a class for the customers Name, Address, Bank Account, Customer and Bank database.

I'm having trouble with creating the class Customer. I want my constructor to accept a Name object, Address object and Bank Account object however I don't remember how to do that. The Name, Address and Bank Account classes are set up already.

This is what I have for the constructor but I'm stuck.

Quote:
public Customer( Name customerName, Address customerAddress, BankAccount customerBankAccount )
{
}
Did I set the constructor up right? If so, what the hell goes in the body?

Suggestions please.
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-25-07, 06:09 PM   #2
rhink
Registered User
 
Join Date: Jul 2005
Posts: 434
Default Re: Sigh, Java HW Help

Quote:
If so, what the hell goes in the body?
You probably want to store the objects you're passing in somewhere...
rhink is offline   Reply With Quote
Old 01-25-07, 06:19 PM   #3
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

So basically just declare variables of those types and assign them to the parameter variables in the body?
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-25-07, 06:24 PM   #4
rhink
Registered User
 
Join Date: Jul 2005
Posts: 434
Default Re: Sigh, Java HW Help

yup.

public class blah {
private SomeObject obj = null;

public blah(SomeObject input) {
obj = input;
}
}
rhink is offline   Reply With Quote
Old 01-25-07, 06:26 PM   #5
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Ah thanks, I think I got it now.

Quote:
public class Customer
{
private Name name ;
private Address address ;
private BankAccount account ;

public Customer(Name n, Address add, BankAccount ba)
{
name = n;
address = add;
account = ba;
}
Correct?
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-25-07, 06:42 PM   #6
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Another question...

All my classes compile, now it's time for a test class. The user will enter the information for each "customer". Would I just need to create one Customer object and then in the parameters create objects for name, address, account etc?

ie:

Customer cust1 = new Customer(new Name(args), new Addres(args), new BankAccount(args)) ;

Is that the best way to do it or does anyone have any suggestions?
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-25-07, 10:47 PM   #7
Cinema4DXL
Registered User
 
Join Date: Sep 2004
Posts: 97
Default Re: Sigh, Java HW Help

that wouldnt be the best way to do it. if your going to have a multiple customers, your going to need to create a list or array possibly to store each unique customer. the way you have it now everytime the user enters information it will recreate the cust1 Customer object (destory anything you previously entered)

but i cant be sure since i dont know the scope of your project
__________________
Athlon XP-M 2600+@(200x11.5) | Abit AN7 | 2x512 Corsair XMS PC-3200 | BFG 6800 GT OC (400/1100) w/ NV Silencer 5 | Promise Ultra133TX2 | WD Caviar SE 80GB 8 MB | Seagate Barracuda 7200.7 160GB | Maxtor DiamondMax 10 300GB | Sony 16x DVD-ROM | NEC 3520A | Antec SmartPower 2.0 500w | Koolance PC-601 | Samsung SyncMaster 997DF
Cinema4DXL is offline   Reply With Quote
Old 01-25-07, 10:56 PM   #8
rhink
Registered User
 
Join Date: Jul 2005
Posts: 434
Default Re: Sigh, Java HW Help

I agree, you probably want a single customer object per customer you have in memory, and store them in whatever your favorite type of list or collection is.
rhink is offline   Reply With Quote

Old 01-25-07, 10:56 PM   #9
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Quote:
Originally Posted by Cinema4DXL
that wouldnt be the best way to do it. if your going to have a multiple customers, your going to need to create a list or array possibly to store each unique customer. the way you have it now everytime the user enters information it will recreate the cust1 Customer object (destory anything you previously entered)

but i cant be sure since i dont know the scope of your project
Thanks but I've actually got past that. I created an array to store the objects and looped the prompts so the user controls when they are done entering customers.

Problem I'm having now is how to print the array using jOptionPane.
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-25-07, 11:14 PM   #10
Cinema4DXL
Registered User
 
Join Date: Sep 2004
Posts: 97
Default Re: Sigh, Java HW Help

try converting what you want to output into a string and print the string into the jOptionPane
__________________
Athlon XP-M 2600+@(200x11.5) | Abit AN7 | 2x512 Corsair XMS PC-3200 | BFG 6800 GT OC (400/1100) w/ NV Silencer 5 | Promise Ultra133TX2 | WD Caviar SE 80GB 8 MB | Seagate Barracuda 7200.7 160GB | Maxtor DiamondMax 10 300GB | Sony 16x DVD-ROM | NEC 3520A | Antec SmartPower 2.0 500w | Koolance PC-601 | Samsung SyncMaster 997DF
Cinema4DXL is offline   Reply With Quote
Old 01-25-07, 11:16 PM   #11
Marvel_us
FOOL!
 
Marvel_us's Avatar
 
Join Date: Dec 2005
Location: Miami, Florida
Posts: 3,754
Default Re: Sigh, Java HW Help

Quote:
Originally Posted by Cinema4DXL
try converting what you want to output into a string and print the string into the jOptionPane
Makes sense, I'll give that a shot.

Thanks.
__________________
Main Rig
Intel Q6600 QUAD|| Gigabyte P35-DS3L ||XFX 7900GTX|| G.Skill 6GB PC2-6400 || OCZ Agility 60GB SSD || WD 320GB + WD Green 1TB HDD || Samsung 20" LCD || CoolMax 650W PSU ||

60gb PS3 Owner
PSNid: Marvel_us
Marvel_us is offline   Reply With Quote
Old 01-25-07, 11:25 PM   #12
Tuork
Official pain in the ass
 
Tuork's Avatar
 
Join Date: May 2003
Location: 127.0.0.1
Posts: 1,197
Send a message via MSN to Tuork
Default Re: Sigh, Java HW Help

I can actually hold my ground pretty well in Java.

What's your problem with JOptionPane?
__________________
My avatar: "An obscure and non sensical pattern made to get people to post what they think it is" - Vamp

Dimitri:
Dell XPS M1530
Core2Duo T5550 1.86Ghz | 3GB DDR2 | 8600M GT 256MB | 250GB Hdd | BenQ FP202W 20" LCD | MX1000 mouse | Inspire T5400 5.1
Tuork is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Diablo 3 hotfix removes monster damage boost in co-op, Inferno teams breathe sigh of News Archived News Items 0 06-11-12 01:20 PM
Google (partially) loses suit to Oracle over use of Java API's ViN86 Mobile Devices And Smartphones 3 05-17-12 10:25 AM
Judge Declines To Rule That Google Pillaged Java News Archived News Items 0 05-10-12 07:00 AM
BAH! I'm being driven insane by Java Virtual Machine Kruno General Software 9 09-01-02 09:59 PM

All times are GMT -5. The time now is 07:46 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.