• Post Reply Bookmark Topic Watch Topic
  • New Topic

Vector Search  RSS feed

 
Robert Staniforth
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have
15 objects,
3 type A, 9 type B, 3 type C
Type A and B objects use class "roomA", type C uses another class "roomB"
They are all in the same vector "v"

I want to search the first 3 elements of the vector for method getCustomer() with return type: null
how on earth do I do that? I've been reading some material provided by my university

i think what they said to do was make an object roomA but they don't explain how to search for a method or how to search multiple elements
so


when I do this, it compiles and I get a result but I need an if statement like:

 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you correctly then just loop through the vector and use an if-statement. Something like if(item instanceof roomA && item.getCustomer() == null) item.addCustomer(c);
 
Robert Staniforth
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!