Hi,
I'm busy studying for my uni exams(java) in October and have come across an interesting "problem" that I would like some help with
Say you have a hifi store that sells hifi combos. The store has a number of items in stock (different speakers, turntables, cd players, dvd players, etc) and a customer can choose a combo that can contain a number of each stock.
Eg.
Combo 1 = Speaker_1 x 2, CD Player_1 x 1, dvd player_1 x 1)
Combo 2 = Speaker_1 x 4, dvd player_1 x 1, TV_1 x 1)
Combo 3 = Speaker_2 x 2, Speaker_1 x 2, TV_1 x 1)
etc...
So all the different combo's will affect the stock level of an item differently when purchased.
The store must keep track of stock levels of each item so that it can reorder when it is low on stock.
I originally thought then that I would have 3 classes, Order, Combo, and StockItem.
Each combo class containing an array of stock items as well as an array which specifies how many of each item is needed in the combo.
Is this the best way to do this?
Actually I first thought that I could keep the number of items in a combo in the actual StockItem class, but then each combo uses a different number of that Item.
Is this the best way to do this? With 2 arrays in the Combo class I mean.
Could I create a new class called ComboItem maybe that contains a StockItem, and also the number of Items in that Combo. So a Combo would contain an array of ComboItems?
But then is it possible to have multiple ComboItems that contain the same StockItem?
I would think it probably be best to look at using a database with all the combos and stock items in tables, but we haven't done database connectivity in the course yet so I'm thinking it's not an option. Besides, not every pc has an Oracle or SQL installed inorder to use database functionality.
What would be the best way to design these classes and their relationships without using a database?
Any hints or advice would be great
I'm busy studying for my uni exams(java) in October and have come across an interesting "problem" that I would like some help with
Say you have a hifi store that sells hifi combos. The store has a number of items in stock (different speakers, turntables, cd players, dvd players, etc) and a customer can choose a combo that can contain a number of each stock.
Eg.
Combo 1 = Speaker_1 x 2, CD Player_1 x 1, dvd player_1 x 1)
Combo 2 = Speaker_1 x 4, dvd player_1 x 1, TV_1 x 1)
Combo 3 = Speaker_2 x 2, Speaker_1 x 2, TV_1 x 1)
etc...
So all the different combo's will affect the stock level of an item differently when purchased.
The store must keep track of stock levels of each item so that it can reorder when it is low on stock.
I originally thought then that I would have 3 classes, Order, Combo, and StockItem.
Each combo class containing an array of stock items as well as an array which specifies how many of each item is needed in the combo.
Is this the best way to do this?
Actually I first thought that I could keep the number of items in a combo in the actual StockItem class, but then each combo uses a different number of that Item.
Is this the best way to do this? With 2 arrays in the Combo class I mean.
Could I create a new class called ComboItem maybe that contains a StockItem, and also the number of Items in that Combo. So a Combo would contain an array of ComboItems?
But then is it possible to have multiple ComboItems that contain the same StockItem?
I would think it probably be best to look at using a database with all the combos and stock items in tables, but we haven't done database connectivity in the course yet so I'm thinking it's not an option. Besides, not every pc has an Oracle or SQL installed inorder to use database functionality.
What would be the best way to design these classes and their relationships without using a database?
Any hints or advice would be great