New Posts  All Forums:Forum Nav:

Java for school???

post #1 of 6
Thread Starter 
Pretty much we had to take an input of license plate numbers and whether or not the car was arriving or departing. however im having some difficulty in fixing the departing part...

anyone think they can help?

alot of the system.outs are for testing and are not needed in the program, all that is needed is to output what is left in the garage to a text file.

THANKS!!! ):

//removed because class mates are copying the code....
Edited by Intresting Enough - 2/2/11 at 7:30am
Supra
(19 items)
 
  
CPUMotherboardGraphicsGraphics
Intel Core i7-2600K 4.0GHz @ 1.160V MSI P67A-GD65 (B3) XFX Radeon HD 6950 2GB Unlocked @ 950/1450 XFX Radeon HD 6950 2GB Unlocked @ 950/1450 
RAMHard DriveHard DriveHard Drive
Mushkin Enhanced Silverline 8GB (2 x 4GB) Corsair Nova SSD 32GB 1TB Seagate 6.0GB/s SATA 1TB Seagate 6.0GB/s SATA 
Optical DriveCoolingOSMonitor
Lite-On DVD Burner Stock Windows 7 Ultimate x64 Acer S231HL LED Monitor 
MonitorMonitorKeyboardPower
Acer S231HL LED Monitor Acer A23IH LCD Monitor eMachines Generic Antec 750W Modular 
CaseMouseMouse Pad
Antec 1200 Gigabyte Ghost 6000 dpi Desk 
  hide details  
Reply
Supra
(19 items)
 
  
CPUMotherboardGraphicsGraphics
Intel Core i7-2600K 4.0GHz @ 1.160V MSI P67A-GD65 (B3) XFX Radeon HD 6950 2GB Unlocked @ 950/1450 XFX Radeon HD 6950 2GB Unlocked @ 950/1450 
RAMHard DriveHard DriveHard Drive
Mushkin Enhanced Silverline 8GB (2 x 4GB) Corsair Nova SSD 32GB 1TB Seagate 6.0GB/s SATA 1TB Seagate 6.0GB/s SATA 
Optical DriveCoolingOSMonitor
Lite-On DVD Burner Stock Windows 7 Ultimate x64 Acer S231HL LED Monitor 
MonitorMonitorKeyboardPower
Acer S231HL LED Monitor Acer A23IH LCD Monitor eMachines Generic Antec 750W Modular 
CaseMouseMouse Pad
Antec 1200 Gigabyte Ghost 6000 dpi Desk 
  hide details  
Reply
post #2 of 6
How far along are you in the java class? There are some data structures that could make this pretty simple.

Vectors in particular would be handy for this you could do a vector of strings and then when they arrive put them into the vector and when they depart find its position using the index of and remove them using the remove method.

http://download.oracle.com/javase/1....il/Vector.html

I am not sure if the garage being full is part or not but that is just what I was thinking.
I will look closer when I get home that was just my initial thought. Sorry if this is not much help maybe someone else will be able to look closer too.
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
Reply
post #3 of 6
my first thought is to use a map to store the data. the key could be the license plate and the value could be the name. adding and removing would be fairly simple.
http://download.oracle.com/javase/1....l/HashMap.html
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
post #4 of 6
Thread Starter 
I wasnt aware that there where multiple ways of doing this. Im fairly new, and ill look into your links. Thanks
Supra
(19 items)
 
  
CPUMotherboardGraphicsGraphics
Intel Core i7-2600K 4.0GHz @ 1.160V MSI P67A-GD65 (B3) XFX Radeon HD 6950 2GB Unlocked @ 950/1450 XFX Radeon HD 6950 2GB Unlocked @ 950/1450 
RAMHard DriveHard DriveHard Drive
Mushkin Enhanced Silverline 8GB (2 x 4GB) Corsair Nova SSD 32GB 1TB Seagate 6.0GB/s SATA 1TB Seagate 6.0GB/s SATA 
Optical DriveCoolingOSMonitor
Lite-On DVD Burner Stock Windows 7 Ultimate x64 Acer S231HL LED Monitor 
MonitorMonitorKeyboardPower
Acer S231HL LED Monitor Acer A23IH LCD Monitor eMachines Generic Antec 750W Modular 
CaseMouseMouse Pad
Antec 1200 Gigabyte Ghost 6000 dpi Desk 
  hide details  
Reply
Supra
(19 items)
 
  
CPUMotherboardGraphicsGraphics
Intel Core i7-2600K 4.0GHz @ 1.160V MSI P67A-GD65 (B3) XFX Radeon HD 6950 2GB Unlocked @ 950/1450 XFX Radeon HD 6950 2GB Unlocked @ 950/1450 
RAMHard DriveHard DriveHard Drive
Mushkin Enhanced Silverline 8GB (2 x 4GB) Corsair Nova SSD 32GB 1TB Seagate 6.0GB/s SATA 1TB Seagate 6.0GB/s SATA 
Optical DriveCoolingOSMonitor
Lite-On DVD Burner Stock Windows 7 Ultimate x64 Acer S231HL LED Monitor 
MonitorMonitorKeyboardPower
Acer S231HL LED Monitor Acer A23IH LCD Monitor eMachines Generic Antec 750W Modular 
CaseMouseMouse Pad
Antec 1200 Gigabyte Ghost 6000 dpi Desk 
  hide details  
Reply
post #5 of 6
Just make a new class that has two instance variables, string licence and boolean arriving and use an array of that object ~_~, no need to import these ADTs for a simple program
post #6 of 6
OP:
Sorry I just am now getting back to you I got busy last night and forgot about looking through your code.

for your original question in the departure it may be better to check
if that array[i] != null then use array[i].equalsIgnoreCase(liscense) instead of array[i] == license

Couple of notes for you your array is too small unless you need to have only so many parking spots. it would actually max at 12 slots or position [11] I am guessing the garage full is not part of the question otherwise the input file would not make a lot of sense.

Quote:
Originally Posted by IKenshinI View Post
Just make a new class that has two instance variables, string licence and boolean arriving and use an array of that object ~_~, no need to import these ADTs for a simple program
If he used an array of a class he would still have the same basic problem of an array that is too small and checking string equality with == instead of the string class .equals or .equalsIgnoreCase. Also a class makes no sense since he does not need a boolean value of arriving or departing he just needs to store the license plates of people arriving and remove license plates of people that depart. Which is why I recommended maybe a vector or arraylist or some other data structure like that would be good because when they arrived he could just .add the license plate number to the list and when they left he could just .remove the license Plate number from the vector. But there are many ways to do this problem I just fail to see how a an array of a class would help.
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming