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



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

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