View Single Post
  #1 (permalink)  
Old 04-15-2008, 03:46 AM
adelgado0723 adelgado0723 is offline
Member
 
Join Date: Apr 2008
Posts: 6
adelgado0723 is on a distinguished road
Searching an arraylist
The assignment requires that I write a program to update, maintain and query students' records on an ongoing basis. It requires a few things, but there's one in specific that I'm stuck on.
This is my Student class:
Code:
public class Student { private String id, firstname, lastname; Student(String i, String f, String l) { id = i; firstname = f; lastname = l; } String getid() { return id; } String getfirstname() { return firstname; } String getlastname() { return lastname; } }
This is my Admissions class:
Code:
import java.util.ArrayList; public class Admissions { Student s; ArrayList<Student> list; int index; boolean found; //2a Admissions() { list = new ArrayList<Student>(); } //2b void add(Student s) { list.add(s); } //2c int size() { return list.size(); } //2d boolean isempty() { return list.isEmpty(); } //2e void search(String key) { if (list.s.getid().equalsIgnoreCase()) { ; } //Prof. didn't tell us how to do this. We need to figure it out, but I think it's with a while loop. } //2f Student remove(int i) { return list.remove(i); } }
My problem is under 2e. I need to "given an id number, locate that record on the list"
Thanks!

Last edited by adelgado0723 : 04-15-2008 at 03:52 AM.
Reply With Quote
Sponsored Links