java - Creating a storage class, sorted and limited by weight -


sorry asking this, use new pov. been sitting on days , can't wrap head around it.

basically, have class screw, object has attributes length, material etc. saves amount of screws , weight amount has.

so sets screw1 = 1cm, steel, 200 screws, 10kg (not of course, simplicities sake)

those screw objects saved in storage unit, sorted. every combination of attributes gets it's own space saved in. limited weight, if add 25kg of screws, you'd need 2 storage spaces, creating new box store them in.

it shall possible take out screws, removing storage space, if weight of box drop below 0 , removing remaining amount of screws new box.

public class schraube { private int schraubenart,material,schraubenanzahl, entnahmeprotokoll; private double durchmesser,laenge, ganghoehe,gaengigkeit,gewicht;  // lots of constructors , methods calculations } 

i had storage class loop through possible combinations of schraube , .add() them arraylist, giving maximum weight.

now, how go doing this? how add stoagespaces if go on weight 20kg? how 1 efficiently without creating huge arrays of 561 spaces times 7?

i hope it's kinda clear trying do. head hurts , can't figure out anymore.

my advise not create storage class since schraube class not represent singular entity properties of multiple entities. in case setting number of screws in class represents screw. there 2 solutions problem.

  1. create getter method calculates number of storage spaces.

    public int getnumberofstoragespaces(){ .... // calculation logic return numberofstoragespaces; }

  2. or can separate type entity quantity. in case remove schraubenanzahl property schraube class, create entity encapsulates type , quantity of screws called schrauben. need storagespace entity represents space , quantity can hold. need entity represents relationship between screws , storage spaces. more complex solution. better understand issue recommend using entity relationship diagram better illustrate relationship between entities.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -