• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logic behind deleting

 
RJ Cavender
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
RJ Cavender
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic