Replace public mutable collection fields/properties with private backing fields and expose them as IReadOnlyList. Add proper methods for mutation (AddItem, AddItems, RemoveItem, SortItems). Changes: - Bin.Items: Now private with AddItem/AddItems/RemoveItem/SortItems - Result.ItemsNotUsed: Now readonly with Add methods - Result.Bins: Now readonly with Add methods - Updated all engine classes to use new encapsulated APIs This improves encapsulation and prevents external code from bypassing business logic by directly manipulating collections. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
875 B
C#
40 lines
875 B
C#
using System.Collections.Generic;
|
|
|
|
namespace SawCut.Nesting
|
|
{
|
|
public class Result
|
|
{
|
|
private readonly List<BinItem> _itemsNotUsed;
|
|
private readonly List<Bin> _bins;
|
|
|
|
public Result()
|
|
{
|
|
_itemsNotUsed = new List<BinItem>();
|
|
_bins = new List<Bin>();
|
|
}
|
|
|
|
public IReadOnlyList<BinItem> ItemsNotUsed => _itemsNotUsed;
|
|
|
|
public IReadOnlyList<Bin> Bins => _bins;
|
|
|
|
public void AddItemNotUsed(BinItem item)
|
|
{
|
|
_itemsNotUsed.Add(item);
|
|
}
|
|
|
|
public void AddItemsNotUsed(IEnumerable<BinItem> items)
|
|
{
|
|
_itemsNotUsed.AddRange(items);
|
|
}
|
|
|
|
public void AddBin(Bin bin)
|
|
{
|
|
_bins.Add(bin);
|
|
}
|
|
|
|
public void AddBins(IEnumerable<Bin> bins)
|
|
{
|
|
_bins.AddRange(bins);
|
|
}
|
|
}
|
|
} |