当前位置: 首页 > news >正文

安徽省水利厅j建设网站高校门户网站系统

安徽省水利厅j建设网站,高校门户网站系统,seo工作前景如何,阿里云做网站选什么主机我需要从以下类列表(Species.java)访问私有变量#xff0c;以便在KlingonOx.java类中使用它们。KlingonOx.java类的目的是确定大象物种的种群数量将大于克林贡牛种的数量。这是Species.java类#xff1a;import java.util.Scanner;public class Species{private String name;…我需要从以下类列表(Species.java)访问私有变量以便在KlingonOx.java类中使用它们。KlingonOx.java类的目的是确定大象物种的种群数量将大于克林贡牛种的数量。这是Species.java类import java.util.Scanner;public class Species{private String name;private int population;private double growthRate;public void readInput(){Scanner keyboard new Scanner(System.in);System.out.println(What is the species name?);name keyboard.nextLine();System.out.println(What is the population of the species?);population keyboard.nextInt();while(population 0){System.out.println(Population cannot be negative.);System.out.println(Reenter population:);population keyboard.nextInt();}System.out.println(Enter growth rate (% increase per year):);growthRate keyboard.nextDouble();}public void writeOutput(){System.out.println(Name name);System.out.println(Population population);System.out.println(Growth rate growthRate %);}public int predictPopulation(int years){int result 0;double populationAmount population;int count years;while( (count0) (populationAmount0) ){populationAmount (populationAmount (growthRate/100) * populationAmount);count --;}if (populationAmount 0)result (int)populationAmount;return result;}public Species(String name){name name;population 0;growthRate 0.0;}public Species(int population){name ;if (population 0)population population;else{System.out.println(ERROR: using a negative population.);System.exit(0);}growthRate 0.0;}public Species(double growthRate){name ;population 0;growthRate growthRate;}public Species(String name, int population, double growthRate){name name;if (population 0)population population;else{System.out.println(ERROR: using a negative population.);System.exit(0);}growthRate growthRate;}public Species(){name ;population 0;growthRate 0;}public void setSpecies(String newName, int newPopulation, double newGrowthRate){name newName;if (newPopulation 0)population newPopulation;else{System.out.println(ERROR: using a negative population.);System.exit(0);}growthRate newGrowthRate;}public void setName(String name){name name;}public void setPopulation(int population){if (population 0)population population;else{System.out.println(ERROR: using a negative population.);System.exit(0);}}public void setGrowthRate(double growthRate){growthRate growthRate;}public String getName(){return name;}public int getPopulation(){return population;}public double getGrowthRate(){return growthRate;}public boolean equals(Species otherObject){return (name.equalsIgnoreCase(otherObject.name)) (population otherObject.population) (growthRate otherObject.growthRate);}}这是KlingonOx.java类import java.util.Scanner;public class KlingonOx extends Species{public static void main(String[] args){new KlingonOx().run();}public void run(){Species klingonox new Species();Species elephant new Species();System.out.println(Please enter data on the species Klingon Ox.);klingonox.readInput();klingonox.writeOutput();klingonox.setPopulation(int population);population population;klingonox.setGrowthRate(double growthRate);growthRate growthRate;System.out.println(Please enter data on the species Elephant.);elephant.readInput();elephant.writeOutput();elephant.setPopulation(population);population population;elephant.setGrowthRate(growthRate);growthRate growthRate;int year 0;if(klingonox.population elephant.population){while(klingonox.population elephant.population){klingonox.population (int)(klingonox.population (klingonox.population * (klingonox.growthRate/100) ) );elephant.population(int)(elephant.population (elephant.population * (elephant.growthRate/100) ) );year;}System.out.println(KLINGON OX EXCEEDS ELEPHANT IN year YEARS);}else{while(klingonox.population elephant.population){klingonox.population(int)(klingonox.population(klingonox.population*(klingonox.growthRate/100)));elephant.population(int)(elephant.population(elephant.population*(elephant.growthRate/100)));year;}System.out.println(ELEPHANT EXCEEDS KLINGON OX IN year YEARS);}}}KlingonOx.java类给出了一个错误即“population”和“growthRate”是Species中的私有实例变量因此无法访问。我曾尝试使用getPopulation和getGrowthRate方法调用来检索变量但我不确定如何正确地执行此操作。感谢任何反馈。
http://www.zqtcl.cn/news/509562/

相关文章:

  • 北京做网站开发公司有哪些网站技术开发文档模板
  • 图解asp.net网站开发实战外管局网站先支后收怎么做报告
  • 访问自己做的网站吗织梦自动生成手机网站
  • 湖南岳阳网站开发网络公司兰州最好的互联网公司
  • 网站上线 流程网站左侧漂浮代码
  • 基于mvc4商务网站开发网站建设引言
  • 深圳网站设计师西安企业100强
  • dz网站数据备份购物网站配色怎么设计
  • 适合网站开发工程师的公司图片百度搜索
  • 网站界面设计需求wordpress single.php
  • 比较权威的房产网站合肥瑶海区地图全图高清版
  • 网站建设公司果动小学电教检查网站建设资料
  • 电子商务网站设计成功的要素青岛网页设计师
  • 门户网站平台建设方案网站开发后如何上线
  • 濮阳做网站的番禺区网络推广渠道
  • 杭州网站seo外包外链图片
  • 苏州网站建设有限公司枣阳建网站
  • 网站开发平台选择如何制作购物网站
  • 专业建设网站企业外包公司企业网站
  • 网站开发需求确认书国家商标注册官网查询系统
  • 国内个人网站建设wordpress 添加搜索
  • 网站建设创新简述网站开发具体流程
  • wordpress小说网站模板南宁企业网站seo
  • 网站开发与设计课程时间网站推广的搜索引擎推广
  • 网站首页幻灯片不显示网页设计制作项目
  • 遂宁网站建设哪家好深圳做响应式网站设计
  • 慈溪建设企业网站wordpress 增加分类字段
  • 毕业设计做系统网站wordpress修改评论框
  • 上海网站开发孵化设计者联盟官网
  • 旅游网站开发需求报告微信创建小程序