This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line!
See this thread for details.
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Filtering Object based on certain Criteria.

 
Ranch Hand
Posts: 162
1
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Geeks

Problem : I Have Objects called T-Shirts in my application, T-shirts have many attributes such as NECK TYPE, FIT TYPE, SIZE, COLOR etc. Now i want the client to be able to get the T-shirts which satisfies all the criteria he mentions, for instance he says i want T-shrits which are black in color , XL size and SLIM fit type OR I want ORANGE color T-Shirts.

I have a T-shirt class inside which i have defined various enums for NECK,FIT,SLEEVES,PRICE,COLOR and so on.

Now i want to write a method which will accept any number of these enums and filters the T-shirt according to that and return the desired result.

getTshirt(Enum... ){} // Logically something of this sort

Could you please tell me the best way of doing this ???


Regards
 
Marshal
Posts: 68026
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put it into a database and let the database do the selecting.
 
Sangel Kapoor
Ranch Hand
Posts: 162
1
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your are right sir, but for some reason i can't put it into database. I am mocking the database thing for now, later ofcourse i will shift it to database and run the sql query to do my job.

 
Campbell Ritchie
Marshal
Posts: 68026
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is probably the wrong way to go about building your app. Build the database first, and the front‑end later.
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!