title: A point of sale application using ArrayList of Item class. How to return isolated/specific values from the list?
body: <p>Java noob here. I am trying to build a simple point of sale checkout application. I have a simple item database in mysql shown in the pic below.</p>
  
  <p><a href="https://i.stack.imgur.com/3cr60.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3cr60.jpg" alt="enter image description here"></a></p>
  
  <p>I have an Item class built as below with getters and setters for each column</p>
  
  <pre><code>public class Item {
  private String itemName;
  private double unitPrice;
  private boolean weightReqd;
  private boolean quanReqd;
  private boolean recalled;
  private boolean ageRest;
  private boolean eCpn;
  private double eCpnAmt;
  
  public Item(){}
  
  public Item(String itemName, double unitPrice, boolean weightReqd, boolean quanReqd, boolean recalled,
              boolean ageRest, boolean eCpn, double eCpnAmt){
      this.itemName = itemName;
      this.unitPrice = unitPrice;
      this.weightReqd = weightReqd;
      this.quanReqd = quanReqd;
      this.recalled = recalled;
      this.ageRest = ageRest;
      this.eCpn = eCpn;
      this.eCpnAmt = eCpnAmt;
  }
  
  public String getItemName() {
      return itemName;
  }
  
  public void setItemName(String itemName) {
      this.itemName = itemName;
  }
  
  public double getUnitPrice() {
      return unitPrice;
  }
  
  public void setUnitPrice(double unitPrice) {
      this.unitPrice = unitPrice;
  }
  
  public boolean isWeightReqd() {
      return weightReqd;
  }
  
  public void setWeightReqd(boolean weightReqd) {
      this.weightReqd = weightReqd;
  }
  
  public boolean isQuanReqd() {
      return quanReqd;
  }
  
  public void setQuanReqd(boolean quanReqd) {
      this.quanReqd = quanReqd;
  }
  
  public boolean isRecalled() {
      return recalled;
  }
  
  public void setRecalled(boolean recalled) {
      this.recalled = recalled;
  }
  
  public boolean isAgeRest() {
      return ageRest;
  }
  
  public void setAgeRest(boolean ageRest) {
      this.ageRest = ageRest;
  }
  
  public boolean iseCpn() {
      return eCpn;
  }
  
  public void seteCpn(boolean eCpn) {
      this.eCpn = eCpn;
  }
  
  public double geteCpnAmt() {
      return eCpnAmt;
  }
  
  public void seteCpnAmt(double eCpnAmt) {
      this.eCpnAmt = eCpnAmt;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And then i am using setters from the Item class to add the records to a List of Items (List). </p>
  
  <pre><code>public class CreateItemList {
  
  private static Connection conn = null;
  public List&lt;Item&gt; itemList = new ArrayList&lt;Item&gt;();
  
  public void createDbConnection() throws ClassNotFoundException, SQLException {
      String myUrl = "jdbc:mysql://localhost:3306/itemdb?autoReconnect=true&amp;useSSL=false";
      conn =  DriverManager.getConnection(myUrl, "******", "*********");
  }
  
  public void addItemsToList() throws SQLException, ClassNotFoundException {
      String query = "SELECT * FROM item_source";
      Statement st = conn.createStatement();
      ResultSet rs = st.executeQuery(query);
  
      try
      {
          while (rs.next())
          {
              Item item = new Item();
              item.setItemName(rs.getString("Item Name"));
              item.setUnitPrice(rs.getDouble("Unit Price"));
              item.setWeightReqd(rs.getBoolean("Weight Reqd"));
              item.setQuanReqd(rs.getBoolean("Quan Reqd"));
              item.setRecalled(rs.getBoolean("Recall"));
              item.setAgeRest(rs.getBoolean("Age Rest"));
              item.seteCpn(rs.getBoolean("Ecpn"));
              item.seteCpnAmt(rs.getDouble("Ecpn Amt"));
  
              itemList.add(item);
          }
      }
      catch (Exception e)
      {
          System.err.println("Got an exception!");
          System.err.println(e);
      }
      st.close();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Now the next thing i want to do is create exception handler methods. So if the user enters an item that is flagged as "true" for weight required, i want the is WeightReqd method to return true. But I'm struggling on this. I'm not sure how to return the boolean value for the item scanned, specifically for the Weight Reqd field.</p>
  
  <pre><code>public class ExceptionsHandler {
  
  public boolean isWeightReqd(List&lt;Item&gt; itemList){
     //HOW DO I RETURN THE BOOLEAN VALUE FOR THE WEIGHT REQD FIELD FROM THE LIST?? 
     return false;
  }
  </code></pre>
  
  <p>Would really appreciate the help! Can also take instructions on the general structure of this program, if there are better ways to do it! </p>