简体   繁体   English

无法弄清楚为什么我不断收到找不到符号编译错误

[英]Can't figure out why i keep getting cannot find symbol compile error

public class CylinderList
{
 private String listName = "";
private ArrayList<Cylinder> cyll = 
         new ArrayList<Cylinder>();

public CylinderList(String listNameIn, 
         ArrayList<Cylinder> cyllIn)                           
{
  listName = listNameIn;
  cyll = cyllIn;
}

public String getName()
{
  return listName;
}

public int numberofCylinders()
{
  return cyll.size();      
}

public double totalArea()
{
  double Area = 0;
  int index = 0;

  if (cyll.size() == 0)
  {
     return 0;
  }

  while (index < cyll.size())
  {
     Area += cyll.get(index).getArea();

     index++;
  }
  return Area;
}

public double totalVolume()
{
  double Volume = 0;
  int index = 0;

  if (cyll.size() == 0)
  {
     return 0;
  }

  while (index < cyll.size())
  {
     Volume += cyll.get(index).getVolume();

     index++;
  }
  return Volume;
}

public double totalHeight()
{
  double Height = 0;
  int index = 0;

  if (cyll.size() == 0)
  {
     return 0;
  }

  while (index < cyll.size())
  {
     Height += cyll.get(index).getHeight();

     index++;
  }
  return Height;
}

public double totalDiameter()
{
  double Diameter = 0;
  int index = 0;

  if (cyll.size() == 0)
  {
     return 0;
  }

  while (index < cyll.size())
  {
     Diameter += cyll.get(index).getDiameter();

     index++;
  }
  return Diameter;
}

public double averageArea()
{
  double aArea = 0;
  int index = 0;

  if (cyll.size() == 0)
  {
     return 0;
  }

  else 
  {
     aArea += totalArea() / cyll.size();
     return aArea;
  }
}

public double averageVolume()
{
  double aVolume = 0;
  int index = 0;

  if (cyll.size() == 0)
  {
     return 0;
  }

  else 
  {
     aVolume += totalVolume() / cyll.size();
     return aVolume;
  }
}
}

I keep getting a cannot find symbol compile time error on getArea, getVolume, getHeight, and getDiameter.我一直在 getArea、getVolume、getHeight 和 getDiameter 上遇到找不到符号编译时错误。 I'm just a beginner so any help would be appreciated.我只是一个初学者,所以任何帮助将不胜感激。 I'm using this with another file but I can't figure out the problem我正在将它与另一个文件一起使用,但我无法弄清楚问题所在

import java.text.DecimalFormat;
public class Cylinder
{

// Fields
private String label = "";
private double radius; 
private double height;
/**
*@param labelIn Command line arguements (not used).
*@param radiusIn Command line arguements (not used).
*@param heightIn Command line arguements (not used).
*/

public Cylinder(String labelIn, double radiusIn, double heightIn) 

{      
  label = labelIn;
  radius = radiusIn;
  height = heightIn;
}
/**
*@return String representation of label. 
*/
public String getlabel()
{
  return label;
}
/**
*@param labelIn The formal parameter for the set label method.
*@return checks to see if labelIn exist.
*/ 
public boolean setlabel(String labelIn)
{
  if (labelIn == null)
  {
     return false;
  }
  else 
  {
     label = labelIn.trim();
     return true;
  }
  }
  /**
  *@return a method to display a double radius.
  */ 
  public double getRadius()
  {
  return radius;
  }
  /**
 *@param radiusIn the formal parameter for the setRadius method.
 */ 
 public void setRadius(double radiusIn)
 { 
  radius = radiusIn;
 }
 /**
 *@return a method to display a double height.
 */ 
 public double getHeight()
 {
  return height;
 }
 /**
 *@param heightIn the formal parameter for the setHeight method.
 */ 
 public void setHeight(double heightIn)
 { 
  height = heightIn;
 }
 /**
 *@return displays diameter when method is called.
 */ 
 public double diameter()
 {
  return radius * 2;
 }
 /**
 *@return displays circumference when method is called.
 */ 
 public double circumference()
 {
  return Math.PI * radius * 2;
 }
 /**
 *@return displays area when method is called.
 */ 
 public double area()
 {
  return 2 * Math.PI * radius * radius + 2 * Math.PI * radius * height;
 }
 /**
 *@return displays volume when method is called.
 */ 
 public double volume()
 {
  return Math.PI * radius * radius * height;
 }
 /**
 *@return displays cylinder information.
 */ 
 public String toString()
 {
  DecimalFormat fmt = new DecimalFormat("#,##0.0##");

  return 
     ("Enter label, radius, and height for a cylinder."
           + "\n\tlabel: " +  label
           +  "\n\tradius: " + fmt.format(getRadius())
           + "\n\theight: " + fmt.format(getHeight()) 
           + "\n\"" + label + "\" is a cylinder with radius = " 
           + fmt.format(getRadius())
           + " units and height = " + fmt.format(getHeight()) + "     units," 
           + "\nwhich has diameter = " + fmt.format(diameter())  
           + " units, circumference = "
           + fmt.format(circumference()) + " units,"
           + "\narea = " + fmt.format(area()) + " square units,"
           + " and volume = " + fmt.format(volume()) + " cubic  units.");


 }
 }

This is Cylinder.这是气缸。

The Code for the Cylinder class type must be available to the compiler because CylinderList class is referencing it. Cylinder 类类型的代码必须可供编译器使用,因为 CylinderList 类正在引用它。 Compiler is not able to find it in the java file being compiled.编译器无法在正在编译的 java 文件中找到它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java-javax.json-编译错误:.getValueType()的“找不到符号”-似乎找不到原因 - Java - javax.json - Compile Error: “cannot find symbol” for .getValueType() - Can't seem to figure out why 每当编译时,我都会不断收到无法找到符号的错误 - Whenever compile, I keep getting the error that it cannot find the symbol 为什么为什么不断出现“找不到符号”错误? - Why do I keep getting “cannot find symbol” error? 我不断收到表达式错误代码的非法开头和“;” 预期的错误代码,我不知道为什么 - I keep getting illegal start of expression error codes and ';' expected error codes and I cannot figure out why 为什么我在编译时会得到“找不到符号”? - Why am I getting a “cannot find symbol” when I compile? 为什么我不断收到缺少符号的编译错误? - Why do I keep getting a compile error for a missing symbol? 我不断收到错误消息:无法找到或加载主类,无法找出原因? - I keep getting Error: Could not find or load main class and cant figure out why? 编译时,为什么在Java程序中出现“找不到符号”错误? - Why am I getting a “cannot find symbol” error in my java program when I compile? 为什么我的程序没有用? 不断获取找不到符号错误? - Why my program no work ? keep getting cannot find symbol error? 绘图程序:不断出现错误,我不知道为什么 - Drawing program: Keep getting errors and I can't figure out why
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM