private void buy(String type, int id) throws DataBaseConnectorException {
           if(type != null){
               int cost = -1;
               if(type.equals("$tank$")){
                   cost = dataBaseConnector.getTankCost(id);
               } else if(type.equals("$armor$")){
                   cost = dataBaseConnector.getArmorCost(id);
               }else if(type.equals("$engine$")){
                   cost = dataBaseConnector.getEngineCost(id);
               }else if(type.equals("$first_weapon$")){
                   cost = dataBaseConnector.getFirstWeaponCost(id);
               }else if(type.equals("$second_weapon$")){
                   cost = dataBaseConnector.getSecondWeaponCost(id);
               }

               if(money >= cost && cost != -1){
                   garage.addPurchase(dataBaseConnector.makePurchase(userId, cost, type,id));
                   money -= cost;
               }else {
                   close();
               }

           }else{
               close();
           }
        }