title: Accessing class A from class B
body: <p>I am doing this piece of school work. its about bin packing problem but its a bit modified about a trolley. There can be two or more piles inside the trolley. What I have done so far is made a parcel class and pile class. There are few rules to this that i need to follow. One of them is that when i put parcel (width 3) inside pile i cant put parcel (width 4) on top of it.</p>
  
  <p>Yes i will have trolley class, pile class and parcel class.</p>
  
  <p>What i am trying to do here make a function inside the pile class that changes the Width of the pile to whatever the width of the Parcel is that was just put in. How do I access parcel width from pile class ? will it just be getW() ? much appreciated the help. Or should i do this inside the trolley class ? not exactly sure how to implement this.</p>
  
  <pre><code>public class Parcel {
  private int H;
  private int W;
  private int customer;
  
  Parcel(int inH, int inW, int inCustomer){
      this.H = inH;
      this.W = inW;
      this.customer = inCustomer;
  }
  
  public int setH(){
  
      int x = (int )(Math.random() * 50 + 1);
  
      return x;
  }
  
  public int setW(){
  
      int y = (int )(Math.random() * 100 + 1);
  
      return y;
  }
  
  public int getW(){
      return W;
  }
  
  public int getH(){
      return H;
  }
  </code></pre>