RLKey = rightList.keys();while(RLKey.hasMoreElements())
{
String accRole = RLKey.nextElement().toString();
print(accRole+\"=\"+this.getRight(accRole));
}
}
/**
*
方法说明:打印信息(过载)
*
输入参数:Object oPara 打印的信息内容
*
返回类型:无
*/
public void print(Object oPara)
{
System.out.println(oPara);
}
/**
*
方法说明:主方法,
*
输入参数:
*
返回类型:
*/
public static void main(String[] args)
{
RoleRight RR = new RoleRight();
RR.init();
RR.print();
RR.print(\"___________________________\");
RR.insert(\"presider\
RR.print();
RR.print(\"___________________________\");
RR.update(\"presider\
RR.print();
RR.print(\"___________________________\");
RR.delete(\"presider\");
RR.print();
}
}//end:)~
package test6;
/**
* Title: 树参数
* Description: 使用继承类,柳树就是树
* Filename: osier.java
*/
class tree
{
/**
*
方法说明:树的树根
*/
public void root()
{
String sSite = \"土壤中\";
String sFunction = \"吸收养份\";
print(\"位置:\"+sSite);
print(\"功能:\"+sFunction);
}
/**
*方法说明:树的树干
*/
public void bolo()
{
String sSite = \"地面\";
String sFunction = \"传递养份\";
print(\"位置:\"+sSite);
print(\"功能:\"+sFunction);
}
/**
*方法说明:树的树枝
*/
public void branch()
{
String sSite = \"树干上\";
String sFunction = \"传递养份\";
print(\"位置:\"+sSite);
print(\"功能:\"+sFunction);
}
/**
*方法说明:树的叶子
*/
public void leaf()
{
String sSite = \"树梢\";
String sFunction = \"光合作用\";
String sColor = \"绿色\";
print(\"位置:\"+sSite);
print(\"功能:\"+sFunction);
print(\"颜色:\"+sColor);
}
/**
*方法说明:显示信息
*输入参数:Object oPara 显示的信息
*/
public void print(Object oPara)
{
System.out.println(oPara);
}
/**
*方法说明:主方法:
*/
public static void main(String[] arges)
{
tree t = new tree();
t.print(\"描述一棵树:\");
t.print(\"树根:\");
t.root();
t.print(\"树干:\");
t.bolo();
t.print(\"树枝:\");
t.branch();
t.print(\"树叶:\");
t.leaf();
}
}
/**
* Title: 柳树参数
* Description: 描述柳树的参数
*/
class osier extends tree
{
/**
*方法说明:过载树的树叶
*/
public void leaf()
{
super.leaf();
String sShape = \"长形\";
super.print(\"形状:\"+sShape);
}
/**
*方法说明:扩展树的花
*/
public void flower()
{
print(\"哈哈,柳树没有花!!\");
}
/**
*方法说明:主方法
*/
public static void main(String[] args)
{
osier o = new osier();
o.print(\"柳树树根:\");
o.root();
o.print(\"柳树树干:\");
o.bolo();
o.print(\"柳树树枝:\");
o.branch();
o.print(\"柳树树叶:\");
o.leaf();
o.print(\"柳树花:\");
o.flower();
}
}
package test7;
/**
* Title: 接口和抽象函数
* Description: 演示继承抽象函数和实现接口
* Filename: newPlay.java
*/
//接口
interface player
{
int flag = 1;
void play();//播放
void pause();//暂停
void stop();//停止
}//end :)
//抽象类
abstract class playing
{
public void display(Object oPara)
{
System.out.println(oPara);
}
abstract void winRun();
}//end :)
//继承了playing抽象类和实现类player接口
public class newPlay extends playing implements player
{
public void play()
{
display(\"newPlay.play()\");//这里只是演示,去掉了代码。
}
public void pause()
{
display(\"newPlay.pause()\");//这里只是演示,去掉了代码。
}
public void stop()
{
display(\"newPlay.stop()\");//这里只是演示,去掉了代码。
}
void winRun()
{
display(\"newPlay.winRun()\");//这里只是演示,去掉了代码。
}
public static void main(String[] args)
{
newPlay p = new newPlay();
p.play();
p.pause();
p.stop();
p.winRun();
}
}//end :)
package test8.com;
/**
* Title: 标识符
* Description: 演示标识符对类的访问控制
* Filename:
*/
public class classDemo1 {
// 公有方法
public void mechod1() {
System.out.println(\"这是一个公有的方法!任何类都可以访问。\");
}
// 授保护的方法
protected void mechod2() {
System.out.println(\"这是一个受到保护的方法!只有子类可以访问。}
// 私有的方法
private void mechod3() {
System.out.println(\"这是一个私有的方法!只有类本身才可以访问。\");
\");
}
public static void main(String[] args) {
classDemo1 d = new classDemo1();
d.mechod1();
d.mechod2();
d.mechod3();
}
}
package test8.com;
/**
* Title: 标识符
* Description: 演示标识符对类的访问控制
* Filename:
*/
public class classPlay
{
public static void main(String[] args){
classDemo1 d = new classDemo1();
d.mechod1();
d.mechod2();
//d.mechod3();
}
}
package test8.net;
import test8.com.classDemo1;
/**
* Title: 标识符
* Description: 演示标识符对类的访问控制
* Filename:
*/
public class classPlay
{
public static void main(String[] args){
classDemo1 d = new classDemo1();
d.mechod1();
//d.mechod2();
//d.mechod3();
}
}
package test9;
/**
* Title: 捕获异常和实现自己的异常
* Description: 通过继承Exception类来实现自己的异常类。并使用try-catch来捕获这个异常。
* Filename:
*/
class MyException extends Exception {
private static final long serialVersionUID = 1L;
public MyException() {
}
public MyException(String msg) {
super(msg);
}
public MyException(String msg, int x) {
super(msg);
i = x;
}
public int val() {
return i;
}
private int i;
}
public class DemoException {
/**
*方法说明:使用MyException类中默认的构造器
*/
public static void a() throws MyException {
System.out.println(\"Throwing MyException from a()\");
throw new MyException();
}
/**
*方法说明:使用MyException类中带信息的构造器
*/
public static void b() throws MyException {
System.out.println(\"Throwing MyException from b()\");
throw new MyException(\"Originated in b()\");
}
/**
*方法说明:使用了MyException中有编码的构造器
*/
public static void c() throws MyException {
System.out.println(\"Throwing MyException from c()\");
throw new MyException(\"Originated in c()\
}
public static void main(String[] args) {
try {
a();
} catch (MyException e) {
e.getMessage();
}
try {
b();
} catch (MyException e) {
e.toString();
}
try {
c();
} catch (MyException e) {
e.printStackTrace();
System.out.println(\"error code: \" + e.val());
}
}
} // end :)
package test10;
import javax.swing.*;
import java.awt.*;
/**
* Title: 创建自己的窗体
* Description:
* Filename:mainFrame.java
*/
public class mainFrame extends JFrame {
private static final long serialVersionUID = 1L;
/**
*方法说明:构造器,通过传递参数来完成窗体的绘制。
*输入参数:String sTitle 窗体标题
*输入参数:int iWidth 窗体的宽度
*输入参数:int iHeight 窗体的高度 返回类型:
*/
public mainFrame(String sTitle, int iWidth, int iHeight) {
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();// 获取屏幕尺寸
ImageIcon ii = new ImageIcon(\"middle.gif\");
setTitle(sTitle);// 设置窗体标题
setIconImage(ii.getImage());// 设置窗体的图标
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);// 设置但关闭窗体时退出程序
setSize(iWidth, iHeight);// 设置窗体大小
int w = getSize().width;// 获取窗体宽度
int h = getSize().height;// 获取窗体高度
System.out.println(\"窗体宽:\" + w + \" 窗体高:\" + h);
int x = (dim.width - w) / 2;
int y = (dim.height - h) / 2;
setLocation(x, y);// 将窗体移到屏幕中间
setVisible(true);// 显示窗体
}
public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);// 使用最新的SWING外观
new mainFrame(\"main Frame Demo\
}
}