Java 从基础到进阶学习之路---类编写以及文档注释.
2014-09-17 09:50
543 查看
Java之前在学习过,基础知识还没有忘光,而且这些高级语言实在是太像,所以那些数据类型,或者循环控制流,以及标准设备等等就直接略过不说了.
不过一些重大概念会穿插在文章的介绍中.
So,这些文章适合于那些有一定高级面向对象语言基础的人阅读.
我们首先编写一个学生类.其主要要求要熟悉的内容是:
关于类构造器(构造方法)的认识和理解.
关于方法的编写.
关于成员变量 & this 的使用,
熟悉了这些内容后,我们就可以按照下面的类图编写这个类了.
构造器的参数有姓名,性别,学号.
类图如下:
我写的参考的代码如下:
我把所有的属性都写成了private类型的,因为这些数据都可写一套set和get方法.....
/**
* Description:
* <br> Blog:<a href = "http://suool.net" target="blnak"> Suool's Blog </a>
* <br> Copyright (c), 2014-2015, SuooL
* <br> This program is writeen by Crazy Java.
* <br> Program name: student.java
* @author: SuooL
* @version: 1.0.0
*/
public class student
{
/// 私有变量
private String Stu_name;
private String Stu_sex ;
private long Stu_Id ;
private int Stu_age;
/**
* Student 的构造方法
* @param name 构造的学生实例姓名
* @param sex 构造的学生实例性别
* @param Id 构造的学生实例学号,开头数字不为零
*/
public student(String name, String sex, long Id)
{
this.Stu_name = name;
this.Stu_sex = sex ;
this.Stu_Id = Id ;
}
/**
* 设置年龄的方法
* @param age 要设置的学生的年龄
*/
public void setAge(int age)
{
this.Stu_age = age;
System.out.println("You set the age of the student " + this.Stu_name + " is " + this.Stu_age);
}
/**
* 获取指定学生的学号
* @return 返回长整型学号值
*/
public long getID()
{
System.out.println("You get the ID of the student " + this.Stu_name + "is" + this.Stu_age);
return this.Stu_Id;
}
/**
* 主方法
* @param args 命令行参数
*/
public static void main(String[] args)
{
// 构造学生对象
student Tom = new student("Tom", "Boy", 122511042);
student Jelly = new student("Jelly", "Girl", 122511043);
Tom.setAge(20);
System.out.println(Tom.getID());
}
}
生成的JavaDoc如下.
Next,下一节写一个小游戏,命令行版的无AI的五子棋.
其实就是对数组和标准输入输出的练习吧.
“If you don't make the time to work on creating the life you want, you're eventually going
to be forced to spend a LOT of time dealing with a life you don't want.” --Kevin Ngo
不过一些重大概念会穿插在文章的介绍中.
So,这些文章适合于那些有一定高级面向对象语言基础的人阅读.
我们首先编写一个学生类.其主要要求要熟悉的内容是:
关于类构造器(构造方法)的认识和理解.
关于方法的编写.
关于成员变量 & this 的使用,
熟悉了这些内容后,我们就可以按照下面的类图编写这个类了.
构造器的参数有姓名,性别,学号.
类图如下:
我写的参考的代码如下:
我把所有的属性都写成了private类型的,因为这些数据都可写一套set和get方法.....
/**
* Description:
* <br> Blog:<a href = "http://suool.net" target="blnak"> Suool's Blog </a>
* <br> Copyright (c), 2014-2015, SuooL
* <br> This program is writeen by Crazy Java.
* <br> Program name: student.java
* @author: SuooL
* @version: 1.0.0
*/
public class student
{
/// 私有变量
private String Stu_name;
private String Stu_sex ;
private long Stu_Id ;
private int Stu_age;
/**
* Student 的构造方法
* @param name 构造的学生实例姓名
* @param sex 构造的学生实例性别
* @param Id 构造的学生实例学号,开头数字不为零
*/
public student(String name, String sex, long Id)
{
this.Stu_name = name;
this.Stu_sex = sex ;
this.Stu_Id = Id ;
}
/**
* 设置年龄的方法
* @param age 要设置的学生的年龄
*/
public void setAge(int age)
{
this.Stu_age = age;
System.out.println("You set the age of the student " + this.Stu_name + " is " + this.Stu_age);
}
/**
* 获取指定学生的学号
* @return 返回长整型学号值
*/
public long getID()
{
System.out.println("You get the ID of the student " + this.Stu_name + "is" + this.Stu_age);
return this.Stu_Id;
}
/**
* 主方法
* @param args 命令行参数
*/
public static void main(String[] args)
{
// 构造学生对象
student Tom = new student("Tom", "Boy", 122511042);
student Jelly = new student("Jelly", "Girl", 122511043);
Tom.setAge(20);
System.out.println(Tom.getID());
}
}
生成的JavaDoc如下.
Next,下一节写一个小游戏,命令行版的无AI的五子棋.
其实就是对数组和标准输入输出的练习吧.
“If you don't make the time to work on creating the life you want, you're eventually going
to be forced to spend a LOT of time dealing with a life you don't want.” --Kevin Ngo
相关文章推荐
- Java 从基础到进阶学习之路---类编写以及文档凝视.
- Java从基础到进阶学习之路----数独小游戏制作(二)
- Java从基础到进阶学习之路----数独小游戏制作(一)
- java语言学习之路之基础常识之java语言特点、开发工具、配置环境变量以及编译工具。
- java语言学习之路之基础常识之java语言特点、开发工具、配置环境变量以及编译工具。
- 一年Java之路的回顾,反思以及展望-Java基础-Java-编程开发
- Java基础--->02.单行注释、多行注释,文档注释和API文档。
- java文档注释 编写格式
- 黑马程序员--Java基础学习之内省(IntroSpector)、注释(Annotation)
- Java学习之路三(static、final以及内部类总结)
- java学习之路--基础
- Java学习之路——利用JDOM对xml文档进行解析等操作实例
- Java 文档&注释 -Java学习笔记(32)
- Java菜鸟学习笔记--配置篇(三):Java API 文档下载与文档注释的使用
- java基础学习之路1
- 黑马程序员_Java基础 数组、数组工具类、文档注释总结
- Java学习之路:不走弯路,就是捷径-Java基础-Java-编程开发
- Jcrontab - java定时程序进阶学习-Java基础-Java-编程开发
- XML文档学习以及规范编写
- java类注释文档编写方法