Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何制作我的程序的JAVADOC?_Java_Javadoc_Dao - Fatal编程技术网

如何制作我的程序的JAVADOC?

如何制作我的程序的JAVADOC?,java,javadoc,dao,Java,Javadoc,Dao,这是我的代码: } 我知道,要发表评论,你必须把//or/*和*/。但是我如何按照JAVADOC规则进行评论呢? 如果你知道怎么做,你能用JAVADOC复制我的代码并把它放在你的答案中吗?谢谢: 请告诉我,JAVADOC是什么,它的用途是什么?有什么简单的方法可以制作它吗?Javadoc是一种注释,您可以在程序中使用它来组织它,使程序更友好,并创建一个包含所有注释的HTML页面,如下所示: 因此,要创建一个javadoc,您将用top put/**代替/*。 在创建javadoc时,您需要知道

这是我的代码:

}

我知道,要发表评论,你必须把//or/*和*/。但是我如何按照JAVADOC规则进行评论呢? 如果你知道怎么做,你能用JAVADOC复制我的代码并把它放在你的答案中吗?谢谢:
请告诉我,JAVADOC是什么,它的用途是什么?有什么简单的方法可以制作它吗?

Javadoc是一种注释,您可以在程序中使用它来组织它,使程序更友好,并创建一个包含所有注释的HTML页面,如下所示:

因此,要创建一个javadoc,您将用top put/**代替/*。 在创建javadoc时,您需要知道一些命令类型

@作者-谁创建了该程序 @抛出-用于异常 @param-方法参数 @return-方法返回的内容

因此,您的javadoc代码如下所示:

/**
  * @author IncredibleCoding
  */
public class Client
{
protected int cod;
protected String name;

/**
  * instance the code passed
  */
public void setCod(int cod) throws Exception
{
  if(cod==null)
  throw new Exception("Invalid code!");

  this.cod = cod;
}

/**
  * @returns the code
  */
public int getCod()
{
  return this.cod;
}

/**
  * instance the name passed
  * @param name, that is the name passed
  * @throws Exception, if the name is in invalid format
  */
public void setName(String name) throws Exception
{
  if(name==null || name.equals("")
  throw new Exception("Invalid name!");

  this.name = name;
}

/**
  * @returns the name 
  */
public String getName()
{
  return this.name;
}

/**
  * the constructor
  * @param cod, that is the code passed
  * @param name, that is the name passed
  */
public Client(int cod, String name) throws Exception
{
  this.setCod(cod);
  this.setName(name);
}

/**
  * @param obj, that is the object that will be compared
  * @returns true if the object is equal to this, false if the object isn't equal
  */
public boolean equals(Object obj)
{
  if(this==obj)
  return true;

  if(obj==null)
  return false;

  if(!(obj instanceof Client))
  return false;

  Client client = (Client)obj;

  if(this.cod!=client.cod)
  return false;

  if(this.name!=client.name)
  return false;

  return true;
}

/**
  * returns the formatted variable like String
  */
public String toString()
{
  return "Code: " + this.cod + "\n" +
         "Name: " + this.name;
}

/**
  * returns the hashCode of a variable
  */
public int hashCode()
{
  int ret = 444;

  ret += ret*7 + new Integer (this.cod).hashCode();
  ret += ret*7 + (this.name).hashCode();

  return ret;
}

/**
  * clone the object
  */
public Object clone()
{
  Client ret = null;

  try
  {
     ret = new Client(this);
  }
  catch(Exception error)
  {
   // this is never null 
  }

  return ret;
}

/**
  * "copy" the variables
  * @param model, that is the object that will be copied
  * @throws Exception, if the model is inexistent
  */
public Client(Client model) throws Exception
{
  if(model==null)
  throw new Exception("Inexistent model!");

  this.cod = model.cod;
  this.name = model.name;
}

}
你应该考虑看看这个甲骨文的页面,这对你也有帮助:

如果你不熟悉这个主题,你真的应该考虑阅读JavaDoc之前尝试编写任何文档。也许首先,大多数IDE都有一些帮助你生成JavaDoc评论的表单有用的功能,也可能探索那些。至于这是为了什么——那你是在伤害自己。IDE还可以使用您的代码和第三方代码中的JavaDocs生成更多信息,并在编写代码时提出建议为什么我得了-6分?我诅咒过某人吗?所以f1sh是有史以来最好的程序员
/**
  * @author IncredibleCoding
  */
public class Client
{
protected int cod;
protected String name;

/**
  * instance the code passed
  */
public void setCod(int cod) throws Exception
{
  if(cod==null)
  throw new Exception("Invalid code!");

  this.cod = cod;
}

/**
  * @returns the code
  */
public int getCod()
{
  return this.cod;
}

/**
  * instance the name passed
  * @param name, that is the name passed
  * @throws Exception, if the name is in invalid format
  */
public void setName(String name) throws Exception
{
  if(name==null || name.equals("")
  throw new Exception("Invalid name!");

  this.name = name;
}

/**
  * @returns the name 
  */
public String getName()
{
  return this.name;
}

/**
  * the constructor
  * @param cod, that is the code passed
  * @param name, that is the name passed
  */
public Client(int cod, String name) throws Exception
{
  this.setCod(cod);
  this.setName(name);
}

/**
  * @param obj, that is the object that will be compared
  * @returns true if the object is equal to this, false if the object isn't equal
  */
public boolean equals(Object obj)
{
  if(this==obj)
  return true;

  if(obj==null)
  return false;

  if(!(obj instanceof Client))
  return false;

  Client client = (Client)obj;

  if(this.cod!=client.cod)
  return false;

  if(this.name!=client.name)
  return false;

  return true;
}

/**
  * returns the formatted variable like String
  */
public String toString()
{
  return "Code: " + this.cod + "\n" +
         "Name: " + this.name;
}

/**
  * returns the hashCode of a variable
  */
public int hashCode()
{
  int ret = 444;

  ret += ret*7 + new Integer (this.cod).hashCode();
  ret += ret*7 + (this.name).hashCode();

  return ret;
}

/**
  * clone the object
  */
public Object clone()
{
  Client ret = null;

  try
  {
     ret = new Client(this);
  }
  catch(Exception error)
  {
   // this is never null 
  }

  return ret;
}

/**
  * "copy" the variables
  * @param model, that is the object that will be copied
  * @throws Exception, if the model is inexistent
  */
public Client(Client model) throws Exception
{
  if(model==null)
  throw new Exception("Inexistent model!");

  this.cod = model.cod;
  this.name = model.name;
}

}