Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

##NAMING

NAMING

##Misc

Misc

##Final Code

Final Code

##NAMING

##Misc

##Final Code

NAMING

Misc

Final Code

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

All the comments here are unnecessary with better variable names. Comments explain why, not what explain why, not what.

All the comments here are unnecessary with better variable names. Comments explain why, not what.

All the comments here are unnecessary with better variable names. Comments explain why, not what.

added 26 characters in body
Source Link
TheCoffeeCup
  • 9.5k
  • 4
  • 38
  • 96
public class Animal {
 
 private static int numberOfAnimals = 0;
 private boolean isWild = true;
 private boolean hasSharpPointyTeeth = false;
 private int age = 0;
 private String sex = "Unknown";
 public Animal() {
 numberOfAnimals++;
 }
 public Animal(String sex, boolean isWild, boolean hasSharpPointyTeeth, int age) {
 this.sex = sex;
 this.isWild = isWild;
 this.hasSharpPointyTeeth = hasSharpPointyTeeth;
 this.age = age;
 numberOfAnimals++;
 }
 public void setIsWild(Boolean isWild) {
 this.isWild = isWild;
 }
 public void setAge(int age) {
 this.age = age;
 }
 public void setHasSharpPointyTeeth(Boolean hasSharpPointyTeeth) {
 this.hasSharpPointyTeeth = hasSharpPointyTeeth;
 }
 public void setSex(String sex) {
 this.sex = sex;
 }
 public Boolean isWild() {
 return isWild;
 }
 public Boolean hasSharpPointyTeeth() {
 return hasSharpPointyTeeth;
 }
 public int getAge() {
 return age;
 }
 public String getSex() {
 return sex;
 }
 public static int getNumberOfAnimals() {
 return numberOfAnimals;
 }
 public String getSpeech() {
 return "Grrrr!";
 }
 public String toString() {
 String out = getSpeech() + "\n" + "Age: " + getAge() + "\n" + "Wild? "
 + isWild() + "\n" + "Has Sharp Pointy Teeth? "
 + hasSharpPointyTeeth() + "\n";
 return out;
 }
 
}
public class Animal {
 
 private static int numberOfAnimals = 0;
 private boolean isWild = true;
 private boolean hasSharpPointyTeeth = false;
 private int age = 0;
 private String sex = "Unknown";
 public Animal() {
 numberOfAnimals++;
 }
 public Animal(String sex, boolean isWild, boolean hasSharpPointyTeeth, int age) {
 this.isWild = isWild;
 this.hasSharpPointyTeeth = hasSharpPointyTeeth;
 this.age = age;
 numberOfAnimals++;
 }
 public void setIsWild(Boolean isWild) {
 this.isWild = isWild;
 }
 public void setAge(int age) {
 this.age = age;
 }
 public void setHasSharpPointyTeeth(Boolean hasSharpPointyTeeth) {
 this.hasSharpPointyTeeth = hasSharpPointyTeeth;
 }
 public void setSex(String sex) {
 this.sex = sex;
 }
 public Boolean isWild() {
 return isWild;
 }
 public Boolean hasSharpPointyTeeth() {
 return hasSharpPointyTeeth;
 }
 public int getAge() {
 return age;
 }
 public String getSex() {
 return sex;
 }
 public static int getNumberOfAnimals() {
 return numberOfAnimals;
 }
 public String getSpeech() {
 return "Grrrr!";
 }
 public String toString() {
 String out = getSpeech() + "\n" + "Age: " + getAge() + "\n" + "Wild? "
 + isWild() + "\n" + "Has Sharp Pointy Teeth? "
 + hasSharpPointyTeeth() + "\n";
 return out;
 }
 
}
public class Animal {
 
 private static int numberOfAnimals = 0;
 private boolean isWild = true;
 private boolean hasSharpPointyTeeth = false;
 private int age = 0;
 private String sex = "Unknown";
 public Animal() {
 numberOfAnimals++;
 }
 public Animal(String sex, boolean isWild, boolean hasSharpPointyTeeth, int age) {
 this.sex = sex;
 this.isWild = isWild;
 this.hasSharpPointyTeeth = hasSharpPointyTeeth;
 this.age = age;
 numberOfAnimals++;
 }
 public void setIsWild(Boolean isWild) {
 this.isWild = isWild;
 }
 public void setAge(int age) {
 this.age = age;
 }
 public void setHasSharpPointyTeeth(Boolean hasSharpPointyTeeth) {
 this.hasSharpPointyTeeth = hasSharpPointyTeeth;
 }
 public void setSex(String sex) {
 this.sex = sex;
 }
 public Boolean isWild() {
 return isWild;
 }
 public Boolean hasSharpPointyTeeth() {
 return hasSharpPointyTeeth;
 }
 public int getAge() {
 return age;
 }
 public String getSex() {
 return sex;
 }
 public static int getNumberOfAnimals() {
 return numberOfAnimals;
 }
 public String getSpeech() {
 return "Grrrr!";
 }
 public String toString() {
 String out = getSpeech() + "\n" + "Age: " + getAge() + "\n" + "Wild? "
 + isWild() + "\n" + "Has Sharp Pointy Teeth? "
 + hasSharpPointyTeeth() + "\n";
 return out;
 }
 
}
Source Link
TheCoffeeCup
  • 9.5k
  • 4
  • 38
  • 96
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /