Java - Data Structures -


i came across java data structures task. i'm looking confirmation understood correctly , approach right.

the task: product can have many different types of attributes, , can vary between products, e.g. bike can have following attributes: {price, color, size} , product kitchen table: {price, width, depth, height}. product attributes organized in hierarchical group structure, product attribute group can contain 1 or several product attributes and/or product attribute groups. write code needed in java handle above described products , print function prints data in such way clear attributes belong product , attribute group if any.

there image attached notation:
image
figure 1: note order important. in figure above attributes 1, attribute 3 , attributes 2 belong product attributes group.

so approach create abstract product class, , make 2 subclasses(bike, kitchentable) extending product class. correct? or entirely different?

please have @ composite pattern.

the composite pattern describes group of objects treated same way single instance of same type of object. matches task have product attributes have organized in hierarchical groups.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -