Hi, first I'd like to introduce myself. I'm a first year comp science undergrad, and this place looks pretty cool, so I'd love to stick around and become a (hopefully) valued member of the forum. I particularly like the terms and conditions when you sign up (... "be nice").
Anyway, down to my problem:
We handed in a project a while ago that was, in a nutshell, to read in data from a .DAT file, store it in appropriate collections, then use a basic query language to filter through the stored data. I wasn't really happy with my querying though, as it was basically a huge succession of control statements. Worked... but it was one monolithic method.
The queries were of the form "select OBJECTNAME where ATRIBUTE COMPARITOR VALUE and ATRIBUTE COMPARITOR VALUE", there could be as many conjugate clauses (the bit after "and") as desired (0... 200 whatever). For example "select planet where magnitude > 2 and rightascension <= 60". Not sure if comparitor is the right
word... What I mean is <=, <, =, >, >= anyway. The objects could be planets, stars etc. Each object has those attributes and is stored in a collection of its own type.
As feedback, we had a comment back that we should have used a Query interface and a two subclasses to represent a simple query (e.g. magnitude > 2) and then a conjunctive query (ie simplequery1 AND simplequery2 ). The Query interface would then have a match method. I'm struggling to get my head around this, does anyone have an example of something similar I can look at or a simple explaination that might help me out?
I've not used interfaces before, I am basically familiar with the concept, but this will be me implementing the concept for the first time... so be gentle!