「java上机浙大」浙大java题库

博主:adminadmin 2022-11-28 03:58:10 70

本篇文章给大家谈谈java上机浙大,以及浙大java题库对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

1、编写一个Application程序【java上机作业,要完整代码,急求!!!!!!!!!!】

第一题:

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

public class RadioTest extends JFrame{

private JRadioButton jrb1;

private JRadioButton jrb2;

private JLabel jlbl;

private JPanel jp;

private JButton jbtn;

private String jlstr;

private ButtonGroup bg;

public RadioTest(){

jlstr = "你选择的是:";

this.setTitle("实现单选按钮的效果");

jrb1 = new JRadioButton("男");

jrb2 = new JRadioButton("女");

bg = new ButtonGroup();

bg.add(jrb1);

bg.add(jrb2);

jlbl = new JLabel(jlstr);

jbtn = new JButton("退出");

jbtn.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

System.exit(1);

}

});

jrb1.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

if(e.getSource()==jrb1){

jlbl.setText(jlstr+jrb1.getText());

}

}

});

jrb2.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

if(e.getSource()==jrb2){

jlbl.setText(jlstr+jrb2.getText());

}

}

});

jp = new JPanel();

jp.add(jrb1);

jp.add(jrb2);

jp.add(jlbl);

jp.add(jbtn);

this.add(jp);

this.setBounds(300, 300, 230, 200);

this.setVisible(true);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args) {

// TODO Auto-generated method stub

RadioTest rt = new RadioTest();

}

}

java上机实验题,要求用java编写,完成其中随便一个就行,急求,能加多少分我就给多少分!!!

package testTime;

import java.util.LinkedList;

public class BinaryTree {

//根节点

private NodeInteger root;

//二叉树中节点数量

private int size;

//无参构造器

public BinaryTree() {

root = new NodeInteger();

}

//数组构造器

public BinaryTree(int[] values) {

System.out.print("新建binaryTree:");

for (int i : values) {

System.out.print(i);

}

System.out.println();

boolean isLeft = true;

int len = values.length;

if (len == 0)

return ;

LinkedListNodeInteger queue = new LinkedListNodeInteger();

root = new NodeInteger(values[0]);

queue.addLast(root);

Node parent = null;

Node current = null;

for (int i=1; ilen; i++) {

current = new NodeInteger(values[i]);

queue.addLast(current);

if (isLeft)

parent = queue.getFirst();

else

parent = queue.removeFirst();

if (isLeft) {

parent.setLeftChild(current);

isLeft = false;

}else {

parent.setRightChild(current);

isLeft = true;

}

}

}

//递归中序遍历

public void inorder() {

System.out.print("binaryTree递归中序遍历:");

inorderTraverseRecursion(root);

System.out.println();

}

//层次遍历

public void layerorder() {

System.out.print("binaryTree层次遍历:");

LinkedListNodeInteger queue = new LinkedListNodeInteger();

queue.addLast(root);

NodeInteger current = null;

while(!queue.isEmpty()) {

current = queue.removeFirst();

if (current.getLeftChild() != null)

queue.addLast(current.getLeftChild());

if (current.getRightChild() != null)

queue.addLast(current.getRightChild());

System.out.print(current.getValue());

}

System.out.println();

}

//获得二叉树深度

public int getDepth() {

return getDepthRecursion(root);

}

private int getDepthRecursion(NodeInteger node){

if (node == null)

return 0;

int llen = getDepthRecursion(node.getLeftChild());

int rlen = getDepthRecursion(node.getRightChild());

int maxlen = Math.max(llen, rlen);

return maxlen + 1;

}

//递归先序遍历

public void preorder() {

System.out.print("binaryTree递归先序遍历:");

preorderTraverseRecursion(root);

System.out.println();

}

private void inorderTraverseRecursion(NodeInteger node) {

// TODO Auto-generated method stub

if (node.getLeftChild() != null)

inorderTraverseRecursion(node.getLeftChild());

System.out.print(node.getValue());

if (node.getRightChild() != null)

inorderTraverseRecursion(node.getRightChild());

}

private void preorderTraverseRecursion(NodeInteger node){

System.out.print(node.getValue());

if (node.getLeftChild() != null)

preorderTraverseRecursion (node.getLeftChild());

if (node.getRightChild() != null)

preorderTraverseRecursion (node.getRightChild());

}

//非递归先序遍历

public void preorderNoRecursion() {

System.out.print("binaryTree非递归先序遍历:");

LinkedListNodeInteger stack = new LinkedListNodeInteger();

stack.push(root);

NodeInteger current = null;

while (!stack.isEmpty()) {

current = stack.pop();

System.out.print(current.getValue());

if (current.getRightChild() != null)

stack.push(current.getRightChild());

if (current.getLeftChild() != null)

stack.push(current.getLeftChild());

}

System.out.println();

}

/**

* 非递归中序遍历

* 栈内保存将要访问的元素

*/

public void inorderNoRecursion() {

System.out.print("binaryTree非递归中序遍历:");

LinkedListNodeInteger stack = new LinkedListNodeInteger();

NodeInteger current = root;

while (current != null || !stack.isEmpty()) {

while(current != null) {

stack.push(current);

current = current.getLeftChild();

}

if (!stack.isEmpty()) {

current = stack.pop();

System.out.print(current.getValue());

current = current.getRightChild();

}

}

System.out.println();

}

/**

* 非递归后序遍历

* 当上一个访问的结点是右孩子或者当前结点没有右孩子则访问当前结点

*/

public void postorderNoRecursion() {

System.out.print("binaryTree非递归后序遍历:");

NodeInteger rNode = null;

NodeInteger current = root;

LinkedListNodeInteger stack = new LinkedListNodeInteger();

while(current != null || !stack.isEmpty()) {

while(current != null) {

stack.push(current);

current = current.getLeftChild();

}

current = stack.pop();

while (current != null (current.getRightChild() == null ||current.getRightChild() == rNode)) {

System.out.print(current.getValue());

rNode = current;

if (stack.isEmpty()){

System.out.println();

return;

}

current = stack.pop();

}

stack.push(current);

current = current.getRightChild();

}

}

public static void main(String[] args) {

BinaryTree bt = new BinaryTree(new int[]{1,2,3,4,5,6,7,8});

bt.inorder();

bt.preorder();

bt.layerorder();

bt.preorderNoRecursion();

bt.inorderNoRecursion();

bt.postorderNoRecursion();

System.out.println("深度为:" + bt.getDepth());

}

}

class NodeV{

private V value;

private NodeV leftChild;

private NodeV rightChild;

public Node(){

};

public Node(V value) {

this.value = value;

leftChild = null;

rightChild = null;

}

public void setLeftChild(NodeV lNode) {

this.leftChild = lNode;

}

public void setRightChild(NodeV rNode) {

this.rightChild = rNode;

}

public V getValue() {

return value;

}

public void setValue(V value) {

this.value = value;

}

public NodeV getLeftChild() {

return leftChild;

}

public NodeV getRightChild() {

return rightChild;

}

}

JAVA上机题目5

package com.sql.animal;

public class Pet {

String name="Pet";

void cry()

{

System.out.println(name+"are crying now.");

}

void eat()

{

System.out.println(name+"are eating now.");

}

}

楼主这是第一个类

我一个一个类提交给你~~~ok?

中国哪些大学学JAVA

去线下的计算机培训机构会更好一点

任何一所大学都不会专门教学生单一的一门课程的 而是全面系统地进行课程设置

如果为了学好JAVA 去线下那种纯粹的计算机培训机构更好 对于Java的课程机构培训的会更加系统详细并且针对就业。

java属于计算机编程语言,就算不上大学也是可以学习到的,所以,你有自己的目标,只要坚持好,报考计算机专业,从基础做起,多打好基础,再加上自学,必有所得。

浙大复试上机所提供的java环境是eclipse吗

之前说不让用java 因为时间不好判断

可是考试现场的时候说可以用java c c++

也确实有eclipse

不知道到你那时候是神马情况了!

java上机浙大的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于浙大java题库、java上机浙大的信息别忘了在本站进行查找喔。

The End

发布于:2022-11-28,除非注明,否则均为首码项目网原创文章,转载请注明出处。