는 최근에 나는 인터뷰에 참석했고이 질문에 주어졌다 :디자인 클래스
질문 :
: 당신과 함께 다음과 같은 기관과, 클래스 다이어그램 또는 골격 코드를 디자인 엔티티는 다음과 같습니다
garment
shirt
pant
fabric
buttons
,787,
The best I could do was this:
class Shirt : Fabric
{
Buttons buttons {get;set;}
//Inherits all Fabric methods
MakeShirt()
{
//make a shirt here
}
}
class Pant : Fabric
{
Buttons buttons {get;set;}
// Inherits all Fabric methods
MakePant()
{
//Make a pant here
}
}
class Fabric
{
private MaterialType materialType {get;set;}
private FabricType fabricType {get;set;}
Fabric(MaterialType mType, FabricType fType)
{
this.materialType = mtype;
this.fabricType = fType;
}
public GetFabricMaterial();
public GetFabricType();
}
class Garment : IGarment
{
Price price {get;set;}
Audience audience {get;set;}
}
enum FabricType
{
Fabric_Formal,
Fabric_Casual,
}
enum MaterialType
{
Fabric_Cotton,
Fabric_Silk,
Fabric_Wool,
}
class Buttons
{
Color color {get;set;}
Shape shape {get;set;}
}
class Zip
{
Color color {get;set;}
Size size {get;set;}
}
하지만 여전히 나는 많은 일들이 위의 골격 코드에서 놓치고 볼 수 있습니다.
MakeShirt()
및 MakePant()
의 반환 형식이 될 수와 Garment
관련 될 수
-
?
- 이러한 질문에 대답하는 동안 어떤 접근 방식이 가장 좋습니까? 즉, 이러한 유형의 질문에 접근하는 방법은 무엇입니까?
여기에 대한 의견을 보내 주시면 감사하겠습니다. (이것이 올바른 질문이 아닌 경우 여기 오른쪽의 stackoverflow 사이트로 옮기시기 바랍니다.)
흠을 우편 있습니다. 셔츠가 직물인가요? 나는 그 옷이 의복이라는 것을 모색하고, 그 옷은 옷감을 가지고 있다고 확신합니다. – spender
셔츠, 바지는 의복입니다. 옷감은 천으로 만들어졌습니다. – Anirudha
@spender : 셔츠가 직물이라고 가정하면 제 수업을 수정하는 방법을 친절하게 가르쳐 주시겠습니까? –