如何构造一个将ageInWeeks和generationNumber设置为零的零参数构造函数,并设置:

时间:2016-05-31 03:56:03

标签: java parameters constructor bluej

  1. 属于DEFAULT GENUS
  2. 物种到DEFAULT SPECIES
  3. isFemale to true
  4. isAlive to true
  5. healthCoefficient to DEFAULT HEALTH COEFFICIENT
  6. identifyNumber为numberOfGuppiesBorn的新增值
  7. 长话短说,目标是在我需要构建构造函数的问题上挣扎。

    我已经阅读了互联网上的例子,但仍然难以理解。

    我拥有的是

        public class Guppy
    {
        public static void main (String[] args)
    {
        int YOUNG_FISH = 10;
        int MATURE_FISH = 30;
        int MAXIMUM_AGE_IN_WEEKS = 50;
        double MINIMUM_WATER_VOLUME_ML = 0.25;
        String DEFAULT_GENUS = "Poecilia";
        String DEFAULT_SPECIES = "reticulata";
        double DEFAULT_HEALTH_COEFFICIENT = 0.5;
        double MINIMUM_HEALTH_COEFFICIENT = 0.0;
        double MAXIMUM_HEALTH_COEFFICIENT = 1.0;
    }
    
    // instance variables - replace the example below with your own
    private String genus;
    private String species;
    private int ageInWeeks;
    private boolean isFemale;
    private int generationNumber;
    private boolean isAlive;
    private double healthCoefficient;
    private int identificationNumber;
    
    
    /**
     * Constructor for objects of class Guppy
     */
    public Guppy()
    {   
    
    
    
    
    
    
    
    
    
    
    
    
    }
    

0 个答案:

没有答案