| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 807 人关注过本帖
标题:[求助]简单的JAVA程序注释
只看楼主 加入收藏
孤竹Forever
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-6-17
收藏
 问题点数:0 回复次数:8 
[求助]简单的JAVA程序注释

自己刚学JAVA..超级领悟不了..
老师的作业.希望有人进来帮帮忙..把源程序后面做个注释..
1.package test.oo.shape;

public abstract class MyShape
{

protected String name;

public abstract double getGirth();

public abstract double getArea();

public abstract String toString();

public String getName()
{
return this.name;
}

public void setName(String name)
{
this.name = name;
}
}
2.package test.oo.shape;


public class Rectangle extends MyShape
{

private double length;
private double width;
public static final String SIDEERR = "长方形的长和宽必须大于0!";

public Rectangle()
{
init();
}

public Rectangle(double a, double b)
{
if ((a <= 0) || (b <= 0))
{
System.err.println(SIDEERR);
init();
}
else
{
this.length = a;
this.width = b;
}
}

private void init()
{
this.length = 5;
this.width = 4;
}

public double getGirth()
{
return (this.length + this.width) * 2;
}
public double getArea()
{
return this.length * this.width;
}
public String toString()
{
return "矩形的名字是:" + this.name + ",长为" + this.length + ",宽为" + this.width;
}
public double getLength()
{
return length;
}
public void setLength(double length)
{
if (length > 0)
{
this.length = length;
}
else
{
System.err.println(SIDEERR);
}
}
public double getWidth()
{
return width;
}
public void setWidth(double width)
{
if (width > 0)
{
this.width = width;
}
else
{
System.err.println(SIDEERR);
}
}
public static void main(String[] args)
{
Rectangle test = new Rectangle();
test.setName("myRectangle");
System.out.println( test.toString());
System.out.println("矩形的周长是:" + test.getGirth());
System.out.println("矩形的面积是:" + test.getArea());
}
}
3.<SCRIPT LANGUAGE="JavaScript">

var total = 0
var play = false
function display(element) {
var now = new Date()
if (!play) {
play = true
startTime = now.getTime()}
if (now.getTime() - startTime > 20000) {
element.checked = !element.checked
return
}
if (element.checked)
total++
else
total--
element.form.num.value = total
}
function restart(form) {
total = 0
play = false
for (var i = 1; i <= 100; ++i) {
form.elements[i].checked = false
}
}

</SCRIPT>


<CENTER>测试你在20秒内能点击多少个框!</CENTER>
<SCRIPT LANGUAGE="JavaScript">

document.write("<FORM><CENTER>")
document.write('<INPUT TYPE="text" VALUE="0" ');
document.write('NAME="num" SIZE=10 onFocus="this.blur()"><BR>')
document.write("<HR SIZE=1 WIDTH=40%>")
for (var i = 0; i < 10; ++i) {
for (var j = 0; j < 10; ++j) {
document.write('<INPUT TYPE="checkbox" ');
document.write('onClick="display(this)">')}
document.write("<BR>")}
document.write("<HR SIZE=1 WIDTH=40%>")
document.write('<INPUT TYPE="button" VALUE="开始" ');
document.write('onClick="restart(this.form)">')
document.write("</CENTER></FORM>")

</SCRIPT>

搜索更多相关主题的帖子: JAVA 注释 
2007-06-17 22:09
孤竹Forever
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-6-17
收藏
得分:0 

我是学文科的.
选修的JAVA..希望大家帮帮忙..

2007-06-18 12:16
geqmoon
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2004-10-16
收藏
得分:0 
我也是新手,只看得懂一些..
PACKAGE 编程还不会啊.

2007-06-18 12:53
孤竹Forever
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-6-17
收藏
得分:0 
2007-06-18 20:32
tockychen
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-2-18
收藏
得分:0 

刚学都写这么长的程序,厉害

2007-06-18 20:36
cx521007
Rank: 1
等 级:新手上路
帖 子:75
专家分:0
注 册:2007-5-28
收藏
得分:0 

package test.oo.shape;//一个包,在test文件夹中的oo文件夹中的shape存在MyShape的字节码.class文件

public abstract class MyShape //定义了一个抽象类
{

protected String name; //受保护的字符型变量

public abstract double getGirth();//抽象方法以下的3个抽象方法都没有方法体

public abstract double getArea();//抽象方法

public abstract String toString();//抽象方法

public String getName()//通过getName()方法获取name变量
{
return this.name;
}

public void setName(String name)//做了一个接口name可以由此处接收来自外部的值
{
this.name = name;
}
}
俺学的也不久~只能做做简单介绍


2007-06-20 12:55
alan3258
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2007-6-17
收藏
得分:0 
厉害 刚刚学的就能写这么多的 厉害 。。。。

珍惜今天
2007-06-20 19:19
大嘴先生2
Rank: 1
等 级:新手上路
威 望:2
帖 子:815
专家分:0
注 册:2006-4-17
收藏
得分:0 
哭了
刚学?
还是选修!~

骑白马的未必是王子,也可能是唐僧;有翅膀的未必是天使,也可能是鸟人。
2007-06-20 20:40
xiang092106
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2007-5-16
收藏
得分:0 

.package test.oo.shape; //定义一个包

public abstract class MyShape //定义一个抽象类
{

protected String name; //定义一个私有字符串变量
/*定义三个抽象方法*/
public abstract double getGirth();

public abstract double getArea();

public abstract String toString();

public String getName()
{
return this.name;//返回当前引用变量值
}

public void setName(String name)
{
this.name = name; //把变量值赋给成员变量
}
}
2.package test.oo.shape; //定义一个包


public class Rectangle extends MyShape
{
/*定义两个私有变量
private double length;
private double width;
public static final String SIDEERR = "长方形的长和宽必须大于0!";
//定义一个静态最终字符串变量值
public Rectangle()
{
init(); //初始化方法
}

public Rectangle(double a, double b)
{
if ((a <= 0) || (b <= 0))
{
System.err.println(SIDEERR); //输出SIDEERR值
init();//初始化方法
}
else
{ /* 把变量赋给当前引用的变量*/
this.length = a;
this.width = b;
}
}

private void init()
{
this.length = 5;
this.width = 4;
}

public double getGirth()
{
return (this.length + this.width) * 2;
}
public double getArea()
{
return this.length * this.width;
}
public String toString()
{
return "矩形的名字是:" + this.name + ",长为" + this.length + ",宽为" + this.width;
}
public double getLength()
{
return length;
}
public void setLength(double length)
{
if (length > 0)
{
this.length = length;
}
else
{
System.err.println(SIDEERR);
}
}
public double getWidth()
{
return width;
}
public void setWidth(double width)
{
if (width > 0)
{
this.width = width;
}
else
{
System.err.println(SIDEERR);
}
}
public static void main(String[] args)
{
Rectangle test = new Rectangle();
test.setName("myRectangle");
System.out.println( test.toString());
System.out.println("矩形的周长是:" + test.getGirth());
System.out.println("矩形的面积是:" + test.getArea());
}
}
3.<SCRIPT LANGUAGE="JavaScript">

var total = 0
var play = false
function display(element) {
var now = new Date()
if (!play) {
play = true
startTime = now.getTime()}
if (now.getTime() - startTime > 20000) {
element.checked = !element.checked
return
}
if (element.checked)
total++
else
total--
element.form.num.value = total
}
function restart(form) {
total = 0
play = false
for (var i = 1; i <= 100; ++i) {
form.elements[i].checked = false
}
}

</SCRIPT>


<CENTER>测试你在20秒内能点击多少个框!</CENTER>
<SCRIPT LANGUAGE="JavaScript">

document.write("<FORM><CENTER>")
document.write('<INPUT TYPE="text" VALUE="0" ');
document.write('NAME="num" SIZE=10 onFocus="this.blur()"><BR>')
document.write("<HR SIZE=1 WIDTH=40%>")
for (var i = 0; i < 10; ++i) {
for (var j = 0; j < 10; ++j) {
document.write('<INPUT TYPE="checkbox" ');
document.write('onClick="display(this)">')}
document.write("<BR>")}
document.write("<HR SIZE=1 WIDTH=40%>")
document.write('<INPUT TYPE="button" VALUE="开始" ');
document.write('onClick="restart(this.form)">')
document.write("</CENTER></FORM>")

以下就简单了.你慢慢体会吧

2007-06-20 21:18
快速回复:[求助]简单的JAVA程序注释
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018353 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved