How to write a simple filtering selection program

Status
Not open for further replies.

Yagisama

Ars Legatus Legionis
33,194
Subscriptor
Someone asked me a question on how to approach designing a simple program that would filter down vehicle selections until you end up with the car model.

For example, given the table below, a GUI would include category with choices of car and truck, and once car is chosen, the choices sedan and coupe are displayed. If coupe is chosen, then Nissan, and Chevy are displayed. And if Nissan is chosen you end up with a 350z.

Assuming the following table is harcoded. My suggestion was to simply query the table with the chosen key C1 and return the strings associated with C1 (Sedan and coupe) for display. And if the user chooses coupe from the GUI, then B2 is used as the key for query and strings Nissan and Chevy are sent to display.

I figured this was the simplest way to do it. Though I'm curious if there is a better way to do this and I'd appreciate any input.

Code:
Category		Body		Make		Model
C1	car	  Sedan	B1	Toyota	M1	Camry
C1	car	  Sedan	B1	Honda	 M2	Accord
C1	car	  Coupe	B2	Nissan	M3	350z
C1	car	  Coupe	B2	Chevy	 M4	Camaro
C2	truck	pickup  B3	Ford	  M5	F-150
C2	truck	pickup  B3	Nissan	M3	Titan
C2	truck	SUV	  B4	Ford	  M5	Expedition
C2	truck	SUV	  B4	Toyota	M1	HIGHLANDER
C2	truck	Van	  B5	Ford	  M5	E-350
 
Status
Not open for further replies.