aspose file tools*
The moose likes Beginning Java and the fly likes Logic behind deleting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Logic behind deleting" Watch "Logic behind deleting" New topic
Author

Logic behind deleting

RJ Cavender
Ranch Hand

Joined: Jul 26, 2006
Posts: 51
Hello, I dont need help per se', I need to know if my logic or way of explaining how this code works is correct. I have code to delete a member record. I got most of it from my instructor's notes though I had to modify it to work with my program. There is an integer that a user enters called menuQuestion. MenuQUestion 3 is an option to delete a member. All the member data is held in individual arrays. Here is the snippet of code;


Am I right in saying the following? What this code does is make the variables unsearchable by taking them out of the slot they are in. So if fname[100] is increased to fname [101], then it's no longer searchable in the spot it was originaly put in. Its essentially been removed but still there....sorta. Make sense?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> All the member data is held in individual arrays.

as a separate exercise to what you're doing now, have a go at making a
class Member
with fields of what the arrays represent.

then you can make an array
Member[] members = new Member[100];
and members[count] = new Member(..,..,..,etc);//in a loop or whatever

much easier to work with.
RJ Cavender
Ranch Hand

Joined: Jul 26, 2006
Posts: 51
Oh im already done. Im just tired of "kinda sorta" understanding how things work. This is a program thats turned in. It works, and works fine..id just like to know im on the right track as far as "how" it works.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

This code is incomplete, so I'm not sure how this would actually work.

My guess of what's intended is that when record is deleted, every record above it should be moved down one slot. For example, if the record at index 10 is deleted, then the record that was at 11 is moved to 10, the record that was at 12 is moved to 11, the record that was at 13 is moved to 12... And so on.

That's not what would happen with the code as posted, but it looks like that might have been the intent.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
RJ Cavender
Ranch Hand

Joined: Jul 26, 2006
Posts: 51
THank you Marc. You most likely (unless i continue with Java) not be hearing from me again. I want to say how much I appreciate the honest help you provide here and how impressive all of your accomplisments are. This is not an easy language by far so excelling at it says something about you guys. Thanks again.
 
jQuery in Action, 2nd edition
 
subject: Logic behind deleting