纯手打,2.(3)没搞清那个命令行是什么意思,所以没写
package student
public class Student {
private String college
private String major
private String classes
private String name
private int oop
private int network
private int sql
private int sum
//无参构造函数
public Student(){}
//有参构造函数
public Student( String college,
String major, String classes,
String name, int oop, int network,
int sql) {
super()
this.college = college
this.major = major
this.classes = classes
this.name = name
this.oop = oop
this.network = network
this.sql = sql
}
//成员方法
public int sum(){
return oop+network+sql
}
//getter,setter方法
public String getCollege() {
return college
}
public void setCollege(String college) {
this.college = college
}
public String getMajor() {
return major
}
public void setMajor(String major) {
this.major = major
}
public String getClasses() {
return classes
}
public void setClasses(String classes) {
this.classes = classes
}
public String getName() {
return name
}
public void setName(String name) {
this.name = name
}
public int getOop() {
return oop
}
public void setOop(int oop) {
this.oop = oop
}
public int getNetwork() {
return network
}
public void setNetwork(int network) {
this.network = network
}
public int getSql() {
return sql
}
public void setSql(int sql) {
this.sql = sql
}
//toString方法
@Override
public String toString() {
return "姓名:"+getName()+" "+"学院:"+getCollege()+" "+"专业:"+getMajor()
+" "+"班级"+getClasses()+" "+"总成绩:"+sum()
}
}
//测试类
package student
import java.util.Scanner
public class MyStudent {
public static void main(String[] args) {
//2.(1)
Student s=new Student()
s.setName("张三")
s.setCollege("南大")
s.setMajor("软件技术")
s.setClasses("软件1班")
s.setOop(89)
s.setNetwork(86)
s.setSql(99)
System.out.println(s)
System.out.println("------------------------------------"
+ "--------------------------------------")
//2.(2)
Student s1=new Student("南大","软件技术","软件1班","李四", 88,98, 91)
System.out.println(s1)
System.out.println("-------------------------------"
+ "-----------------------------------------")
//2.(3)
Scanner a=new Scanner(System.in)
System.out.println("请输入学院:")
String college=a.next()
System.out.println("请输入专业:")
String major=a.next()
System.out.println("请输入班级:")
String classes=a.next()
System.out.println("请输入姓名:")
String name=a.next()
System.out.println("请输入面向对象程序设计成绩:")
int oop=a.nextInt()
System.out.println("请输入网络原理成绩:")
int network=a.nextInt()
System.out.println("请输入姓名数据库成绩:")
int sql=a.nextInt()
Student s2=new Student(college,major,classes,name,oop,network,sql)
System.out.println(s2)
}
}
/*** @param args
之前在大学的时候写的一个二叉树算法,运行应该没有问题,就看适不适合你的项目了 */
public static void main(String[] args) {
BiTree e = new BiTree(5)
BiTree g = new BiTree(7)
BiTree h = new BiTree(8)
BiTree l = new BiTree(12)
BiTree m = new BiTree(13)
BiTree n = new BiTree(14)
BiTree k = new BiTree(11, n, null)
BiTree j = new BiTree(10, l, m)
BiTree i = new BiTree(9, j, k)
BiTree d = new BiTree(4, null, g)
BiTree f = new BiTree(6, h, i)
BiTree b = new BiTree(2, d, e)
BiTree c = new BiTree(3, f, null)
BiTree tree = new BiTree(1, b, c)
System.out.println("递归前序遍历二叉树结果: ")
tree.preOrder(tree)
System.out.println()
System.out.println("非递归前序遍历二叉树结果: ")
tree.iterativePreOrder(tree)
System.out.println()
System.out.println("递归中序遍历二叉树的结果为:")
tree.inOrder(tree)
System.out.println()
System.out.println("非递归中序遍历二叉树的结果为:")
tree.iterativeInOrder(tree)
System.out.println()
System.out.println("递归后序遍历二叉树的结果为:")
tree.postOrder(tree)
System.out.println()
System.out.println("非递归后序遍历二叉树的结果为:")
tree.iterativePostOrder(tree)
System.out.println()
System.out.println("层次遍历二叉树结果: ")
tree.LayerOrder(tree)
System.out.println()
System.out.println("递归求二叉树中所有结点的和为:"+getSumByRecursion(tree))
System.out.println("非递归求二叉树中所有结点的和为:"+getSumByNoRecursion(tree))
System.out.println("二叉树中,每个节点所在的层数为:")
for (int p = 1p <= 14p++)
System.out.println(p + "所在的层为:" + tree.level(p))
System.out.println("二叉树的高度为:" + height(tree))
System.out.println("二叉树中节点总数为:" + nodes(tree))
System.out.println("二叉树中叶子节点总数为:" + leaf(tree))
System.out.println("二叉树中父节点总数为:" + fatherNodes(tree))
System.out.println("二叉树中只拥有一个孩子的父节点数:" + oneChildFather(tree))
System.out.println("二叉树中只拥有左孩子的父节点总数:" + leftChildFather(tree))
System.out.println("二叉树中只拥有右孩子的父节点总数:" + rightChildFather(tree))
System.out.println("二叉树中同时拥有两个孩子的父节点个数为:" + doubleChildFather(tree))
System.out.println("--------------------------------------")
tree.exChange()
System.out.println("交换每个节点的左右孩子节点后......")
System.out.println("递归前序遍历二叉树结果: ")
tree.preOrder(tree)
System.out.println()
System.out.println("非递归前序遍历二叉树结果: ")
tree.iterativePreOrder(tree)
System.out.println()
System.out.println("递归中序遍历二叉树的结果为:")
tree.inOrder(tree)
System.out.println()
System.out.println("非递归中序遍历二叉树的结果为:")
tree.iterativeInOrder(tree)
System.out.println()
System.out.println("递归后序遍历二叉树的结果为:")
tree.postOrder(tree)
System.out.println()
System.out.println("非递归后序遍历二叉树的结果为:")
tree.iterativePostOrder(tree)
System.out.println()
System.out.println("层次遍历二叉树结果: ")
tree.LayerOrder(tree)
System.out.println()
System.out.println("递归求二叉树中所有结点的和为:"+getSumByRecursion(tree))
System.out.println("非递归求二叉树中所有结点的和为:"+getSumByNoRecursion(tree))
System.out.println("二叉树中,每个节点所在的层数为:")
for (int p = 1p <= 14p++)
System.out.println(p + "所在的层为:" + tree.level(p))
System.out.println("二叉树的高度为:" + height(tree))
System.out.println("二叉树中节点总数为:" + nodes(tree))
System.out.println("二叉树中叶子节点总数为:" + leaf(tree))
System.out.println("二叉树中父节点总数为:" + fatherNodes(tree))
System.out.println("二叉树中只拥有一个孩子的父节点数:" + oneChildFather(tree))
System.out.println("二叉树中只拥有左孩子的父节点总数:" + leftChildFather(tree))
System.out.println("二叉树中只拥有右孩子的父节点总数:" + rightChildFather(tree))
System.out.println("二叉树中同时拥有两个孩子的父节点个数为:" + doubleChildFather(tree))
}
}
教科书的广发卡晚上刚发完看过发手机看过发色尽快发噶色戒咖啡咖色开发哈色开发和业务看哈可谓机关副安慰噶啬己奉公被误解与国防意识到好处不像你这个色结果服务员的根本那种效果也经常被误解而应该都不会改变vsdbfeyd 上的价格法ukeybfsdncgbsjgfawkueygju 是上的价格发生看见的服务噶尔科技要花费高标准新建供电局上的价格发生的进口国发生大家看法告诉大家看功夫世界大会规范设计的符合该世界富商大贾说过的后果是大家分工孙晋芳是