I've been giving objects a try, but i tryed to make a little search function and it doesn't seem to be working out,
static void mod(Vector v) {
System.out.print("Reg to search: ");
String readx = new String();
Keyboard.skipLine();
readx = Keyboard.readString();
for(int i = 0; i < v.size(); i++) {
Object p = v.elementAt(i);
car c2 = (car)p;
if(c2.reg == readx)
System.out.println(c2.make + "\t:\t" + c2.reg + "\t:\t" + c2.numdays + "\t:\t" + "E " + c2.cost + "\n");
}
Thats the main program code, The car class is has a String called "reg" inside it. What im trying to do is get it to downcast and then compare the readx to the c2.reg and if it matches, then print out that object,
Any help would be great!
Thanks,
~ Idgeitman


Sign In
Create Account

Guest_idgeitman_*
Back to top









