Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,227,573 members, 8,070,813 topics. Date: Wednesday, 05 February 2025 at 10:49 AM |
Nairaland Forum / Science/Technology / Programming / Help On Java (9795 Views)
Pls Help Me With Ebooks On Java,d Price For The Book Is High And Am Still A Teen / Anyone With Help On Java App Creation? / [Help Request] Help On Java download and Installation Oo! (2) (3) (4)
(1) (2) (3) (4) (5) (Reply) (Go Down)
Re: Help On Java by Dolemite(f): 1:10am On Apr 27, 2011 |
Thanks alot, silly me i could KISS you right now lol, it really helped, but I would also need to a remove passenger functionality. . . EDIT**I modified the code thus; public class AircraftI get a 'null' whenever i run the checkPass() method, why is that? |
Re: Help On Java by segsalerty(m): 1:35am On Apr 27, 2011 |
Dolemite: are u female? if(true) 1 million times coz we have few female java programmers. Sure, u can remove a Passanger by saying
including the function above can do it , it will remove the passanger from the ArrayList of u provide the passanger name on the list ! Hope this helps ? |
Re: Help On Java by Dolemite(f): 1:39am On Apr 27, 2011 |
Edited. . . Thanks |
Re: Help On Java by segsalerty(m): 1:43am On Apr 27, 2011 |
Dolemite:works ? u welcome thou |
Re: Help On Java by Dolemite(f): 1:46am On Apr 27, 2011 |
EDIT**I modified the code thus; public class AircraftI get a 'null' whenever i run the checkPass() method, why is that? I haven't tried that one though, the remove command. . . |
Re: Help On Java by segsalerty(m): 1:54am On Apr 27, 2011 |
Dolemite: u got this wrong use this
ur coding logic is kinda poor, are u copying/modifying any code there? |
Re: Help On Java by Dolemite(f): 11:56am On Apr 27, 2011 |
I tried your code, it still doesn't work. . . |
Re: Help On Java by segsalerty(m): 3:10pm On Apr 27, 2011 |
Thats the modules logic my friend, It depends on ur class structure and how u implementing it. Try to fix it, if u cant, zip all ur src codes and send to my mail : segsalerty@yahoo.com |
Re: Help On Java by Dolemite(f): 5:02pm On Apr 27, 2011 |
public class AircraftModule what now? anyway this one works, please have a look and tell me if my logic is faulty. . . |
Re: Help On Java by segsalerty(m): 6:34pm On Apr 27, 2011 |
U did quite well with d Aircraft class desing, its just looking as if u re getting stucked trying to get ur class properties. Well, i get ur logic, will do smth to it when i connect to my PC tonite, coz am on mobile rite nw. Pls, be patient wit me. ****when i said nothing wrong wit the modules i provoded to u earlier, i meant those functions i provided to u will do there job as u required if u use them in the right way in ur class to suit ur need. |
Re: Help On Java by segsalerty(m): 10:14pm On Apr 27, 2011 |
this shld help? |
Re: Help On Java by Dolemite(f): 10:36pm On Apr 28, 2011 |
Thanks, good to have a genius like you here, you're the ONLY useful person here on nairaland!! |
Re: Help On Java by Fayimora(m): 12:13am On Apr 29, 2011 |
Thanks, good to have a genius like you here, you're the ONLY useful person here on nairaland!! Hehehe !!!! |
Re: Help On Java by segsalerty(m): 12:31am On Apr 29, 2011 |
Dolemite: U are so much welcome! u dnt need to thank me again, u already gave the sweet some post back! lolz And mind u, am not the ONLY useful person here on nairaland ooo ! pls, dnt make my head over-swell oooo! We so much have so many talented people on here. ok? Fayimora: Da Main Boss, whats that suppose to mean ? |
Re: Help On Java by Fayimora(m): 8:24am On Apr 29, 2011 |
Just feeling the comment man! |
Re: Help On Java by candylips(m): 8:37pm On Apr 29, 2011 |
segsalerty: You can declare p inside the addPass method. no need making it an instance variable |
Re: Help On Java by Dolemite(f): 3:07am On May 01, 2011 |
I tried to use the remove passenger method but i get a 'concurrent modification exception' error at runtime. |
Re: Help On Java by candylips(m): 11:24am On May 01, 2011 |
^^ |
Re: Help On Java by Dolemite(f): 10:47pm On May 01, 2011 |
Segs where are youuuuuuuuuuuuuuuuuu?? |
Re: Help On Java by candylips(m): 10:53pm On May 01, 2011 |
removed |
Re: Help On Java by Dolemite(f): 11:05pm On May 01, 2011 |
Segs has a better knowledge of my code. I appreciate your help. |
Re: Help On Java by Fayimora(m): 12:55am On May 02, 2011 |
Segs has a better knowledge of my code. I appreciate your help. Lmao, wow! but thats a bit harsh on those that wanted to help and I would have fallen into that cause i wanted to help. Would get Segs for you now, |
Re: Help On Java by Dolemite(f): 1:05am On May 02, 2011 |
Lol, no no he's been helping me with the code, all help is welcomed please. . . |
Re: Help On Java by Fayimora(m): 1:12am On May 02, 2011 |
Alright, so what do you have and what do you want to do? |
Re: Help On Java by segsalerty(m): 2:39am On May 02, 2011 |
candylips:u wanna remove me ? or think i ran away ? Dolemite: U really love to make my head swell the more, My Head will just Burst one day and there will be No Segsalerty to call again after my head is gone off my body, there are other dudes that are very brilliant here, nobody is [b]Perfect[/b]est Fayimora: Lol Dude, she really didnt means to, she is just kinda used to giving me those kisses , u know ? but, this time around, its your turn to have some sweet kisses on your lips to show alot of Appreciation after u've helped her! Thanks in advance Dolemite: Good ! u just spoken well So, post the problem code so that he can help u, what if i travelled nko? |
Re: Help On Java by Dolemite(f): 8:31am On May 02, 2011 |
public class AircraftHow can I implement a remove passenger method in this code that searches for the passenger by name and removes the whole object of the passenger. . . |
Re: Help On Java by csharpjava(m): 10:41am On May 02, 2011 |
Dolemite How can I implement a remove passenger method in this code that searches for the passenger by name and removes the whole object of the passenger. . .Try this method: [s]public void RemovePassenger(ArrayList<Passengers> pass){ int index = pass.indexOf(name); if (index != -1) { pass.remove(name); } else { System.out.println("passanger not in list" } return; } [/s] Sorry these should be done with an Iterator |
Re: Help On Java by Dolemite(f): 11:16am On May 02, 2011 |
Thanks alot, but how do i test for this? and does it take off the whole object from the list? eg. objectofaircraft.RemovePassenger("John" // won't compile. |
Re: Help On Java by 2muchlogic(m): 11:50am On May 02, 2011 |
csharpjava: The code is incorrect, you are passing an ArrayList of Passenger objects when you should have sent the Passenger object, then you are checking for the "name" (which is a Passenger Object Attribute - String Object) from a data structure that contains Passenger Objects |
Re: Help On Java by Dolemite(f): 12:04pm On May 02, 2011 |
2much what do you suggest I do? |
Re: Help On Java by 2muchlogic(m): 12:46pm On May 02, 2011 |
Dolemite: The solution: The Passenger Object is incomplete, by the look of things each Passenger has 4 variables: name,fare,weight,luggage. None of these attributes are unique. In the REAL WORLD each passenger is UNIQUE and the details will be stored in a database; hence each passenger will be identified by an exclusive passenger NUMBER. So your class would be something like: public class Passenger { int passengerID; int seats; String name; int luggage; public Passenger(int seats, String name, int luggage, int passengerID) { this.passengerID = passengerID; this.seats = seats; this.name = name; this.luggage = luggage; } } Now you can create Passengers with Unique Ids and this is equivalent to imitating a database. An sql query would be something like: DELETE FROM passengers WHERE passengerID = some_passengerID; so in code we could write: public void removePassenger(int pId) { //Iterate through the arrayList and check for the ID //Once you find the Passenger with the correct ID use the remove(Object) method of the ArrayList } ********** This problem could be solved easier by using a HashMap instead of an ArrayList ********* |
Re: Help On Java by Fayimora(m): 1:22pm On May 02, 2011 |
You probably want to look up Maps, Thats exactly what you need to give the perfect algorithm. Its also designed to help in problems like this |
Female Programmers Stand Up And Be Counted / How Do I Write Sql Statemen That Can Cast String To Double / Q-basic Program To Compute Simple Interest.
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2025 Oluwaseun Osewa. All rights reserved. See How To Advertise. 52 |