public class Guitar
{
private String SerialNumber ;
private double Price;
private String Model;
private Type Type;
private Builder Builder;
private Wood BackWood;
private Wood TopWood;
}
Firstly I have this class in the OOAD -HeadFirst book.
This Guitar class used also Search(Guitar) method for searching guitars. Then create new class GuitarSpec as:
internal class GuitarSpec
{
public Builder Builder { get; set; }
public string Model { get; set; }
public Enums.Type Type { get; set; }
public Wood BackWood { get; set; }
public Wood TopWood { get; set; }
}
The Guitar class uses this class like this:
internal class Guitar
{
public string SerialNumber { get; set; }
public double Price { get; set; }
public GuitarSpec GuitarSpec { get; set; }
}
In the SearchMethod(GuitarSpec) method, it's using the author also explain that as encapsulation. But I can't understand that why this encapsulation. For example mostly encapsulation example that private field public methods or constructor parameters. This code how become encapsulation of OOP?