선생님이 저에게이 과제를주었습니다. 전체 프로그램을 완벽하게 작동 시켰지만 4 단계에서 이해할 수없는 부분이 있습니다. 여기서는 declawed 값을 설정하는 방법을 과부하 상태로 설정하려고합니다. 이 프로그램에서 부울 값을 설정하기 위해 Cat 클래스의 set 메서드를 사용하여 잘못된 질문을 던지려고합니다. 왜 내가 과부하 방법이 필요할까요? 누군가가 주제에 대해 생각할만한 것을 제공 할 수 있다면 그것은 대단 할 것입니다. 감사!자바 부울 오버로드 된 설정 메서드
1.Create a new class called Cat that includes the functionality below
2.The new class has the attributes of:
name – type String
age – type integer
weight – type double
breed - type String
declawed - type boolean - true for has no claws, false for has claws
3. Be sure your classes have a reasonable complement of constructor, accessor and
mutator methods. Every member variable must have at least one independent accessor and
one independent mutator.
4. Example:
public void setName(String name) mutator used to set name
public void setBreed(String breed) mutator used to set the breed
public void set(Boolean declawed) used to set claws or not
***(You must overload the set method to set deClawed value)****
public String getName() accessor used to get name
public String getBreed() accessor used to get breed
public boolean getBoolean() access used to get the value of declawed
다음은 올바른 출력입니다.
예 실행 : 고양이 1의 이름을 입력 : 샘
고양이 1의 나이를 입력하기 : 1
고양이 1의 무게를 입력하면 : 5
고양이 1의 품종을 입력 : fluffy1
고양이가 발톱을 가지고 있습니까? 참 또는 거짓? : 참
:
이 코드를 사용해보십시오. 저, 또는 벙어리 교수 (당연히 무례 함). –