189 8069 5689

包含Java描写植物代码的词条

哪位大侠可以帮我写一段java代码!是关于根据数据库里的数据来形成一个动态树形图

这是代码,你可以自己调试一下。

我们提供的服务有:网站设计制作、成都做网站、微信公众号开发、网站优化、网站认证、蕲春ssl等。为数千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的蕲春网站制作公司

数据结构如下:

CREATE TABLE dtree (

id int,

pid int,

name varchar(200),

url varchar(200),

title varchar(200),

target varchar(200),

icon varchar(200),

iconopen varchar(200),

opened bit);

为了实现获取数据库变量功能,需要建立一个DTree类,并编译生成CLASS文件,放入\WEB-INF\classes文件夹下。

DTree类代码如下:

package work3;

public class DTree {

private int id;

private int pid;

private String name;

private String url;

private String title;

private String target;

private String icon;

private String iconOpen;

private int opened;

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public int getPid() {

return pid;

}

public void setPid(int pid) {

this.pid = pid;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getUrl() {

return url;

}

public void setUrl(String url) {

this.url = url;

}

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public String getTarget() {

return target;

}

public void setTarget(String target) {

this.target = target;

}

public String getIcon() {

return icon;

}

public void setIcon(String icon) {

this.icon = icon;

}

public String getIconOpen() {

return iconOpen;

}

public void setIconOpen(String iconOpen) {

this.iconOpen = iconOpen;

}

public int getOpened() {

return opened;

}

public void setOpened(int opened) {

this.opened = opened;

}

}

work3.jsp代码如下:

%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%

%@ page import="java.sql.*"%

jsp:useBean id='settree' scope="application" class="work3.DTree" /

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

""

html

head

meta http-equiv="Content-Type" content="text/html; charset=GB18030"

link rel="StyleSheet" href="dtree.css" type="text/css" /

script type="text/javascript" src="dtree.js"/script

titledTree in MySQL/title

/head

body

h2

Example

/h2

div class="dtree"

p

a href="javascript: d.openAll();"open all/a |

a href="javascript: d.closeAll();"close all/a

/p

script type="text/javascript"

!--

d = new dTree('d');

%

//驱动程序名

String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";

//数据库用户名

String userName = "sa";

//密码

String userPwd = "1";

//数据库名

String dbName = "master";

//表名

String tableName = "dtree";

//连接字符串

String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName="+dbName;

//加载驱动

Class.forName(driverName).newInstance();

//连接数据库

java.sql.Connection conn = DriverManager.getConnection(url,userName,userPwd);

//得到Statement实例

java.sql.Statement statement = conn.createStatement();

//查询数据

String sql = "select * from " + tableName;

//返回结果

java.sql.ResultSet rs = statement.executeQuery(sql);

//获取变量

while (rs.next()) {

settree.setId(rs.getInt(1));

settree.setPid(rs.getInt(2));

settree.setName(rs.getString(3));

settree.setUrl(rs.getString(4));

settree.setTitle(rs.getString(5));

settree.setTarget(rs.getString(6));

settree.setIcon(rs.getString(7));

settree.setIconOpen(rs.getString(8));

settree.setOpened(rs.getInt(9));

if(settree.getPid()==0)

settree.setOpened(1);

%

d.add(%=settree.getId()%,%=settree.getPid()%,'%=settree.getName()%','%=settree.getUrl()%','%=settree.getTitle()%','%=settree.getTarget()%','','',%=settree.getOpened()%);

%

}

%

document.write(d);

//--

/script

/div

/body

/html

求JAVA编程代码…………

下面是WINDOW界面的代码,用JAVA SWING写的。

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class PlusWhile {

//主面板

private JFrame mainTop = null;

private JPanel inPanel = null; //输入面板

private JPanel outPanel = null;//输出面板

private JButton count = null; //按钮

private JTextField inText = null; // 输入文本框

private JTextField result = null;//结果文本框

private JLabel resultOut = null;//输出提示

private JLabel remindIn = null;//输入提示

//初始化方法

private void init() {

//组件实例化

mainTop = new JFrame("阶乘计算器");

inPanel = new JPanel();

outPanel = new JPanel();

count = new JButton("计算");

inText = new JTextField(10);

result = new JTextField(10);

resultOut = new JLabel("计算的结果:");

remindIn = new JLabel("请输入要计算的正整数:");

//添加输入组件

inPanel.add(remindIn);

inPanel.add(inText);

inPanel.add(count);

//添加输出组件

outPanel.add(resultOut);

outPanel.add(result);

result.setEnabled(false);

//设置布局样式

mainTop.setLayout(new BorderLayout());

//主面板添加组件

mainTop.add(inPanel, BorderLayout.NORTH);

mainTop.add(outPanel, BorderLayout.SOUTH);

//设置监听

count.addActionListener(new ButtonListener());

//设置屏显位置

mainTop.setLocation(350 , 300);

mainTop.pack();

mainTop.setVisible(true);

mainTop.setAlwaysOnTop(true);

//设置关闭事件

mainTop.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

//监听类

private class ButtonListener implements ActionListener {

public void actionPerformed(ActionEvent event) {

int inputNum = 0;

String input = inText.getText();

//若输入为非数字,提示错误

try {

inputNum = Integer.parseInt(input);

}catch(Exception e) {

inputNum = -1;

}

//输入数值小于0,提示错误

if(inputNum 0) {

inText.setText("请输入正确的数值!");

result.setText("");

}

else if(inputNum == 0) {//输入值为0处理

result.setText("1");

}

else {//输入值为正整数,计算阶乘

int temp = inputNum;

while(inputNum 1) {

temp *= --inputNum;

}

result.setText(temp + "");

}

}

}

//入口方法

public static void main(String[] args) {

new PlusWhile().init();

}

}

有什么不明白的继续补充,呵呵。 加点儿分不。

java代码写一个zoo类,要求生成若干个Animal.fish.和bird.并调用他们的属性和方

public class zoo{

String name;

int age;

public zoo(String a,int b){

name = a;

age = b;

}

public String getName(){

return name;

}

public int getAge(){

return age;

}

public static void main(String args[]) {

zoo animal1 = new zoo(fish,1);

zoo animal2 = new zoo(bird,2);

String m = animial1.getName();

String n = animial2.getName();

String p = animal1.age;

String q = animal2.age;

System.out.println("动物为 +m +年龄为+p+");

System.out.println("动物为 + n+年龄为+q+");

}

}

说明,本人只是自己输入的代码,并没有调试,只是告诉你一个框架或是模板,如果需要别的功能,自己添加即可。调试不过,可以在问我,我会告诉你的。

跪求JAVA代码三叶玫瑰线 r=asin3θ或r=acos3θ。谢谢

三叶玫瑰并不是植物,你也说啦,是专门研究数学的。其实是一种三叶玫瑰线的 java代码

S 3:

输入下面程序用于输出三叶玫瑰线的图形,三叶玫瑰线的参数方程为:

x = r * sin(3t)* sin(t);y = r *sin(3t) * sin(t) 其中: 0 = t = 2 * 3.14159

#include stdio.h

#include math.h

#define RADIUS 12

#define PII 3.14159

void main(void)

{

char tx[2 * RADIUS + 1][2 * RADIUS + 1];

int nT;

int nX;

int nY;

double dbD;

for(nX = 0; nX 2 * RADIUS + 1; nX++)

{

for(nY = 0; nY 2 * RADIUS + 1; nY++)

{

tx[nX][nY] = '';

}

}

for(nT = 0; nT = 360; nT += 4)

{

dbD = nT * PII / 180;

nX = (int)(RADIUS * sin(3 * dbD) * sin(dbD)) + RADIUS;

nY = (int)(RADIUS * sin(3 * dbD) * cos(dbD)) + RADIUS;

tx[nX][nY] = '*';

}

for(nX = 0; nX 2 * RADIUS + 1; nX++)

{

for(nY = 0; nY 2 * RADIUS + 1; nY++)

{

printf("%2c", tx[nX][nY]);

}

printf("\n");

}

}


分享标题:包含Java描写植物代码的词条
网页网址:http://jkwzsj.com/article/hcigss.html

其他资讯