Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Help with a Java program
New Posts  All Forums:Forum Nav:

Help with a Java program - Page 2

post #11 of 16
Quote:
Originally Posted by Ike View Post

Warning: Spoiler! (Click to show)
tom.slick is correct about how you use the class. Before you were simply using it like a variable. The point of a class to be able to create an object, as he showed. However you don't need to use a hashmap, that is more complicated for you to understand. Simply declare one or more bankAccounts as follows:

BankAccount account1 = new BankAccount();
BankAccount account2 = new BankAccount();

and reference like
account1.getBalance();

To tom.slick - if he didn't know to correctly use a class, you shouldn't be describing a more complicated way of declaring an object in list or a hashmap. keep it simply for him. While it might be a better, cleaner way to do it, that is not what he is learning at the moment. People have to learn to walk before they can run. And if I was the instructor and I was teaching someone how to declare a class, and they came back with using a hashmap I would be suspicious of how they came up with that unless they excelled the entire time in the class.

If I would of turned in an assignment on classes with a hashmap in my Java class , my teacher would have given me a 0 unless I could run through the code line by line and explain the logic of it all haha.
Quote:
Originally Posted by yui129 View Post

Thank you for simplifying it for me. Should I replace my methods with those?

A "trick" my teacher used to help the people in our class struggling with learning how classes worked, was making you remember that "String" variables aren't a primitive data type. Strings are a class, so any class you make must be used similarly to a String. So for this program, .getBalance() is comparable .equals() in the sense that they're both methods of the class. Hope this helped!
post #12 of 16
Quote:
Originally Posted by Failuyr View Post

If I would of turned in an assignment on classes with a hashmap in my Java class , my teacher would have given me a 0 unless I could run through the code line by line and explain the logic of it all haha.
A "trick" my teacher used to help the people in our class struggling with learning how classes worked, was making you remember that "String" variables aren't a primitive data type. Strings are a class, so any class you make must be used similarly to a String. So for this program, .getBalance() is comparable .equals() in the sense that they're both methods of the class. Hope this helped!

=D in my "Web pages for buisnesses" class they were teaching it using dreamweaver... The final basically had a page with a form that when you click submit it would validate the fields and send an email... but it really doesnt send an email because its linked to nothing. So, i decided to write mine with ASXP and C# in the backend where i linked it to my gmail account had my password converted into binary so even though i showed the code, my password wasnt clear text. My page actually emailed on the form submit. (And yes, i know i could have secured it a lotmore, but at least it was quick and easy.)

... It was sad to see that half the class come in wondering why their pages wouldnt work on this computer, but it worked at home. (Static Paths) ... sigh... class was a waste of time for me, but at least it counted for an elective.
Zev's Comp
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Sandy Bridge 3.3GHz GIGABYTE GA-Z68X-UD3H-B3 LGA 1155 Intel Z68 HDM... GeForce GTX 750 Ti G.SKILL Ripjaws X Series 8GB 
Hard DriveHard DriveHard DrivePower
1TB HDD 64GB SSD (Used for SRT) 500 GB. Antec BP550 Plus 550W Continuous Power ATX12V V... 
Case
COOLER MASTER ELITE 335 RC-335-KKN1-GP Black S... 
  hide details  
Reply
Zev's Comp
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Sandy Bridge 3.3GHz GIGABYTE GA-Z68X-UD3H-B3 LGA 1155 Intel Z68 HDM... GeForce GTX 750 Ti G.SKILL Ripjaws X Series 8GB 
Hard DriveHard DriveHard DrivePower
1TB HDD 64GB SSD (Used for SRT) 500 GB. Antec BP550 Plus 550W Continuous Power ATX12V V... 
Case
COOLER MASTER ELITE 335 RC-335-KKN1-GP Black S... 
  hide details  
Reply
post #13 of 16
Dealing with Bank Account? Need to discuss locking and cohesion! thumb.gif
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
post #14 of 16
Quote:
Originally Posted by DuckieHo View Post

Dealing with Bank Account? Need to discuss locking and cohesion! thumb.gif
And use of Decimal instead of Float and so on. Don't use Float for money related operations. Alternatively use int or long and save the currency in cents (e.g. $1.00 = 100 in int).
Edited by gonX - 4/8/14 at 7:10am
#well
(18 items)
 
Lenovo L530
(8 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4770k Gigabyte Z87X-UD4H Sapphire RX 580 2x G.Skill F3-2400C10-8GTX 
Hard DriveOptical DriveCoolingOS
Samsung 840 EVO Generic DVD±RW Burner Noctua NH-D14 Windows 10 
MonitorMonitorKeyboardPower
Dell U2711 Samsung SyncMaster 2233 Ducky DK9008 Overclock.net Edition, Cherry MX B... Corsair TX850 
CaseMouseMouse PadAudio
Fractal Design Core 2500 Logitech G303 QPAD HeatoN L M-Audio Fast Track USB 
AudioAudio
Beyerdynamic DT-770 80 Ohm AntLion ModMic v3 
CPUGraphicsRAMRAM
Intel Ivy Bridge 3210M Intel HD 4000 Graphics OEM Hard Mounted Corsair Vengeance  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 3 240GB DVD-+RW Arch Linux 1600x900 TN 
  hide details  
Reply
#well
(18 items)
 
Lenovo L530
(8 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4770k Gigabyte Z87X-UD4H Sapphire RX 580 2x G.Skill F3-2400C10-8GTX 
Hard DriveOptical DriveCoolingOS
Samsung 840 EVO Generic DVD±RW Burner Noctua NH-D14 Windows 10 
MonitorMonitorKeyboardPower
Dell U2711 Samsung SyncMaster 2233 Ducky DK9008 Overclock.net Edition, Cherry MX B... Corsair TX850 
CaseMouseMouse PadAudio
Fractal Design Core 2500 Logitech G303 QPAD HeatoN L M-Audio Fast Track USB 
AudioAudio
Beyerdynamic DT-770 80 Ohm AntLion ModMic v3 
CPUGraphicsRAMRAM
Intel Ivy Bridge 3210M Intel HD 4000 Graphics OEM Hard Mounted Corsair Vengeance  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 3 240GB DVD-+RW Arch Linux 1600x900 TN 
  hide details  
Reply
post #15 of 16
Quote:
Originally Posted by gonX View Post

And use of Decimal instead of Float and so on. Don't use Float for money related operations. Either use int or long and save the currency in cents (e.g. $1.00 = 100 in int) as an int.

Excellent point! This got me once a decade ago when I was an intern writing a spreadmart to calculate a money market allocations.

He also probably should range checking to protect from negative withdrawals/deposits and overflows as well.


[Secure systems are hard!]
Edited by DuckieHo - 4/8/14 at 7:06am
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
post #16 of 16
Quote:
Originally Posted by DuckieHo View Post

Excellent point! This got me once a decade ago when I was an intern writing a spreadmart to calculate a money market allocations.

He also probably should range checking to protect from negative withdrawals/deposits and overflows as well.


[Secure systems are hard!]

Depending on what language you're programming in, you should probably consider checking if your language supports something similar to the checked keyword in C#.
#well
(18 items)
 
Lenovo L530
(8 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4770k Gigabyte Z87X-UD4H Sapphire RX 580 2x G.Skill F3-2400C10-8GTX 
Hard DriveOptical DriveCoolingOS
Samsung 840 EVO Generic DVD±RW Burner Noctua NH-D14 Windows 10 
MonitorMonitorKeyboardPower
Dell U2711 Samsung SyncMaster 2233 Ducky DK9008 Overclock.net Edition, Cherry MX B... Corsair TX850 
CaseMouseMouse PadAudio
Fractal Design Core 2500 Logitech G303 QPAD HeatoN L M-Audio Fast Track USB 
AudioAudio
Beyerdynamic DT-770 80 Ohm AntLion ModMic v3 
CPUGraphicsRAMRAM
Intel Ivy Bridge 3210M Intel HD 4000 Graphics OEM Hard Mounted Corsair Vengeance  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 3 240GB DVD-+RW Arch Linux 1600x900 TN 
  hide details  
Reply
#well
(18 items)
 
Lenovo L530
(8 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4770k Gigabyte Z87X-UD4H Sapphire RX 580 2x G.Skill F3-2400C10-8GTX 
Hard DriveOptical DriveCoolingOS
Samsung 840 EVO Generic DVD±RW Burner Noctua NH-D14 Windows 10 
MonitorMonitorKeyboardPower
Dell U2711 Samsung SyncMaster 2233 Ducky DK9008 Overclock.net Edition, Cherry MX B... Corsair TX850 
CaseMouseMouse PadAudio
Fractal Design Core 2500 Logitech G303 QPAD HeatoN L M-Audio Fast Track USB 
AudioAudio
Beyerdynamic DT-770 80 Ohm AntLion ModMic v3 
CPUGraphicsRAMRAM
Intel Ivy Bridge 3210M Intel HD 4000 Graphics OEM Hard Mounted Corsair Vengeance  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 3 240GB DVD-+RW Arch Linux 1600x900 TN 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Help with a Java program