public?class?RandomUtils?{
成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務,包含不限于做網(wǎng)站、網(wǎng)站建設、西華網(wǎng)絡推廣、微信平臺小程序開發(fā)、西華網(wǎng)絡營銷、西華企業(yè)策劃、西華品牌公關、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;成都創(chuàng)新互聯(lián)公司為所有大學生創(chuàng)業(yè)者提供西華建站搭建服務,24小時服務熱線:18980820575,官方網(wǎng)址:aaarwkj.com
public?static?String?randomId(){
Random?random?=?new?Random();
StringBuilder?sb?=?new?StringBuilder();
for?(int?i?=?0;?i??6;?i++)?{
sb.append(random.nextInt(10));
}
return?sb.toString();
}
public?static?int?randomIntId(){
Random?random?=?new?Random();
StringBuilder?sb?=?new?StringBuilder();
for?(int?i?=?0;?i??6;?i++)?{
sb.append(random.nextInt(10));
}
return?Integer.parseInt(sb.toString());
}
public?static?String?randomName(){
String[]?name1?=?{"趙","錢","孫","李","周","吳","鄭","王","張","劉"};
String[]?name2?=?{"一","二","三","四","五","六","七","八","九","十"};
Random?random?=?new?Random();
StringBuilder?sb?=?new?StringBuilder();
sb.append(name1[random.nextInt(10)]);
sb.append(name2[random.nextInt(10)]);
sb.append(name2[random.nextInt(10)]);
return?sb.toString();
}
public?static?String?randomSex(){
Random?random?=?new?Random();
return?random.nextInt(4)/2==0?"男":"女";
}
public?static?int?randomAge(int?min,?int?max){
Random?random?=?new?Random();
return?random.nextInt(min)?+?max-min;
}
public?static?int?randomScore(){
Random?random?=?new?Random();
return?(int)(random.nextDouble()*100%100);
}
public?static?String?randomAddress(){
String[]?address1?=?{"商業(yè)","紅葉","安康","河南","長海","黃河","桐柏","科學","瑞達","花園"};
String[]?address2?=?{"東","南","西","北","中"};
String[]?address3?=?{"街","路","大道","巷"};
Random?random?=?new?Random();
StringBuilder?sb?=?new?StringBuilder();
sb.append(address1[random.nextInt(10)]);
sb.append(address2[random.nextInt(5)]);
sb.append(address3[random.nextInt(4)]);
sb.append(random.nextInt(1000)+1);
sb.append("號");
return?sb.toString();
}
}
import?javax.swing.*;
import?javax.swing.event.TreeSelectionEvent;
import?javax.swing.event.TreeSelectionListener;
import?javax.swing.table.DefaultTableModel;
import?javax.swing.tree.DefaultMutableTreeNode;
import?java.awt.*;
import?java.util.*;
import?java.util.List;
public?class?StudentManage?extends?JFrame{
public?final?static?String[]?CH_NUM?=?{"一","二","三","四","五","六","七","八","九","十"};
public?final?static?String?ROOT?=?"班級管理";
public?final?static?int?GRADE_NUM?=?3;
public?final?static?int?CLASS_NUM?=?3;
private?MapString,?ListStudent?classes;
public?StudentManage()?{
setTitle("學生管理系統(tǒng)");
setSize(300,?300);
setLayout(new?BorderLayout());
if(classes?==?null)?classes?=?new?HashMap();
DefaultMutableTreeNode?top?=?new?DefaultMutableTreeNode(ROOT);
DefaultMutableTreeNode[]?gradeNodes?=?new?DefaultMutableTreeNode[GRADE_NUM];
for?(int?i?=?0;?i??GRADE_NUM;?i++)?{
gradeNodes[i]?=?new?DefaultMutableTreeNode(CH_NUM[i]?+?"年級");
for?(int?j?=?0;?j??CLASS_NUM;?j++)?{
gradeNodes[i].add(new?DefaultMutableTreeNode(CH_NUM[j]?+?"班"));
}
top.add(gradeNodes[i]);
}
final?JTree?tree?=?new?JTree(top);
String?title[]?=?{"ID","姓名","性別","年齡","地址"};
final?DefaultTableModel?model?=?new?DefaultTableModel(title,?0);
JTable?table=new?JTable(model);
tree.addTreeSelectionListener(new?TreeSelectionListener()?{
@Override
public?void?valueChanged(TreeSelectionEvent?e)?{
DefaultMutableTreeNode?node?=?(DefaultMutableTreeNode)?tree?.getLastSelectedPathComponent();
if?(node?==?null)?return;
Object?object?=?node.getUserObject();
if?(node.isLeaf())?{
ListStudent?stdList?=?classes.get(getFullPath(node));
Object[][]?data?=?new?Object[stdList.size()][5];
for?(int?i?=?0;?i??stdList.size();?i++)?{
data[i][0]?=?stdList.get(i).getId();
data[i][1]?=?stdList.get(i).getName();
data[i][2]?=?stdList.get(i).getSex();
data[i][3]?=?stdList.get(i).getAge();
data[i][4]?=?stdList.get(i).getAddress();
}
while(model.getRowCount()0){
model.removeRow(model.getRowCount()-1);
}
for?(int?i?=?0;?i??stdList.size();?i++)?{
model.addRow(data[i]);
}
model.fireTableDataChanged();
}
}
});
add(tree,?BorderLayout.WEST);
add(new?JScrollPane(table),?BorderLayout.CENTER);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private?String?getFullPath(DefaultMutableTreeNode?defaultMutableTreeNode){
StringBuilder?sb?=?new?StringBuilder();
Object[]?objs?=?defaultMutableTreeNode.getUserObjectPath();
for?(int?i?=?0;?i??objs.length;?i++)?{
sb.append(objs[i]);
}
return?sb.toString().replace(ROOT,"");
}
public?void?init(){
for?(int?i?=?0;?i??GRADE_NUM;?i++)?{
for?(int?j?=?0;?j??CLASS_NUM;?j++)?{
int?n?=?new?Random().nextInt(30)+1;
ListStudent?stdList?=?new?ArrayList(n);
for?(int?k?=?0;?k??n;?k++)?{
stdList.add(new?Student(RandomUtils.randomIntId(),RandomUtils.randomName(),RandomUtils.randomSex(),
RandomUtils.randomAge(6,12),RandomUtils.randomAddress()));
}
classes.put(CH_NUM[i]?+?"年級"+?CH_NUM[j]?+"班",?stdList);
}
}
}
public?static?void?main(String[]?args)?{
StudentManage?studentManage?=?new?StudentManage();
studentManage.init();
}
}
class?Student?{
private?int?id;
private?String?name;
private?String?sex;
private?int?age;
private?String?address;
public?Student(int?id,?String?name,?String?sex,?int?age,?String?address)?{
this.id?=?id;
this.name?=?name;
this.sex?=?sex;
this.age?=?age;
this.address?=?address;
}
public?Student()?{
}
public?int?getId()?{
return?id;
}
public?String?getName()?{
return?name;
}
public?String?getSex()?{
return?sex;
}
public?int?getAge()?{
return?age;
}
public?String?getAddress()?{
return?address;
}
@Override
public?String?toString()?{
return?"Student{"?+
"id="?+?id?+
",?name='"?+?name?+?'\''?+
",?sex='"?+?sex?+?'\''?+
",?age="?+?age?+
",?address='"?+?address?+?'\''?+
'}';
}
}
關于這個問題不知道你是想要Java的實現(xiàn)代碼還是如何設計這個系統(tǒng)?
1. 如果是要代碼,那么只能自己到網(wǎng)絡上看看是否有類似的程序。
我的建議你可以搜索一些財務/費用管理的一些小軟件完全滿足班費管理的需求,看看是否有類似的代碼。
2. 如果是咨詢設計思路
系統(tǒng)相對比較簡單,類似一個小的費用管理系統(tǒng),收錢和花錢;1)以班級為單位記錄班級的班費收入,2)支出班費是關鍵需要能夠維護班費的費用類型(設置可以有2級、3級細分便于統(tǒng)計);3)支出時記錄費用所支出的費用所屬類型;4)匯總統(tǒng)計分析、明細報表分析
/**
* GenericLinkedStack.java
*/
package fix;
import java.util.EmptyStackException;
/**
*泛型的鏈式棧數(shù)據(jù)結構
*/
public class GenericLinkedStackE {
// 棧頂元素
private Item top = null;
// 返回棧頂元素,并彈出
public E pop() throws EmptyStackException {
if (isEmpty()) {
throw new EmptyStackException();
}
E e = top.value;
top = top.next;
return e;
}
/**
* 棧頂壓入一個元素
* @param e 被壓入的元素
*/
public void push(E e) {
Item curr = new Item(e);
curr.next = top;
top = curr;
}
/**
* 返回棧頂元素,但不出棧
* @return 棧頂元素
*/
public E peek() {
if (isEmpty()) {
throw new EmptyStackException();
}
return top.value;
}
/**
* 判斷棧是否為空
* @return 判斷結果
*/
public boolean isEmpty() {
return top == null;
}
/**
* 棧中元素
* @author jilen
*
*/
class Item {
//元素
private E value;
//下一個
private Item next;
public Item(E e) {
this.value = e;
}
public E getValue() {
return value;
}
public void setValue(E value) {
this.value = value;
}
public Item getNext() {
return next;
}
public void setNext(Item next) {
this.next = next;
}
}
}
/**
* InfixToPostfixConverter.java
*/
package fix;
import java.util.Hashtable;
/**
* @author jilen
*
*/
public class InfixToPostfixConverter {
// 操作符及其優(yōu)先級組成的鍵值對
private static final HashtableCharacter, Integer operators;
private StringBuffer infix;
private StringBuffer postfix;
GenericLinkedStackCharacter stack = new GenericLinkedStackCharacter();
// 初始化操作符列表,static語句塊會在加載類時自動執(zhí)行
static {
operators = new HashtableCharacter, Integer();
operators.put('^', 4);
operators.put('*', 3);
operators.put('/', 3);
operators.put('%', 3);
operators.put('+', 2);
operators.put('-', 2);
operators.put('(', -1);
operators.put(')', 5);
}
/**
*
*/
public InfixToPostfixConverter(StringBuffer infix, StringBuffer postfix) {
this.infix = infix;
this.postfix = postfix;
}
/**
* 轉(zhuǎn)換函數(shù)
*/
public void convertToPostfix() {
// 對輸入字符串中字符遍歷
for (int i = 0, n = infix.length(); i n; i++) {
char c = infix.charAt(i);
// 是數(shù)字之間添加到轉(zhuǎn)換后字符串
if (isNumber(c)) {
postfix.append(c);
} else if (isOperator(c)) {
switch (c) {
// '(' 直接入棧
case '(':
stack.push(c);
break;
// ')' 彈出元素直到碰到'('
case ')':
while (!stack.isEmpty() stack.peek() != '(') {
postfix.append(stack.pop());
}
stack.pop();
break;
// 其他操作符
default:
// 當前操作符比棧頂操作符優(yōu)先級高,直接入棧
if (stack.isEmpty() || precedence(c, stack.peek())) {
stack.push(c);
}
// 當前操作符比棧頂操作符優(yōu)先級低,出棧直到為空或棧頂優(yōu)先級低于當前操作符
else if (!precedence(c, stack.peek())) {
while (!stack.isEmpty() !precedence(c, stack.peek())) {
postfix.append(stack.pop());
}
stack.push(c);
}
break;
}
}
}
// 若棧中還有操作符,所以元素出棧
while (!stack.isEmpty()) {
postfix.append(stack.pop());
}
}
/**
* 判斷是否為操作符
* @param c
* @return
*/
public static boolean isOperator(char c) {
return operators.containsKey(c);
}
/**
* 優(yōu)先級大小關系operator1 operator2 則返回true,否則false
* @param operator1
* @param operator2
* @return 判斷結果
*/
public static boolean precedence(char operator1, char operator2) {
return operators.get(operator1) operators.get(operator2);
}
/**
* 是否數(shù)字
* @param c 要判斷的字符
* @return 判斷結果
*/
public static boolean isNumber(char c) {
return c = '0' c = '9';
}
}
/**
*Main.java測試類
*/
package fix;
/**
* @author Administrator
*
*/
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
StringBuffer infix = new StringBuffer("(1+2)*3/4");
StringBuffer postfix = new StringBuffer();
InfixToPostfixConverter converter = new InfixToPostfixConverter(infix,
postfix);
converter.convertToPostfix();
System.out.println(postfix.toString());
}
}
中綴轉(zhuǎn)后綴的程序,有GenericLinkedStack.java,InfixToPostfix.java,Main.java三個源文件需要放在fix包下
當前題目:java班級管理系統(tǒng)代碼 班級管理系統(tǒng)的代碼
本文網(wǎng)址:http://aaarwkj.com/article18/docpegp.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信公眾號、虛擬主機、App開發(fā)、動態(tài)網(wǎng)站、軟件開發(fā)、網(wǎng)站導航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)