查询宿舍信息java代码 查询宿舍信息java代码是什么
JAVA编程请定义一个寝室类,内容自拟!
寝室类如下:
创新互联公司是一家专业提供上虞企业网站建设,专注与成都网站设计、网站建设、成都h5网站建设、小程序制作等业务。10年已为上虞众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。
import java.util.List;
import java.util.Objects;
public class Bedroom {
private String place;
private String manager;
private Integer bedCount;
private Integer tableCount;
private ListPerson persons;
private char sexFlag;//男:1 女:2
public String getPlace() {
return place;
}
public void setPlace(String place) {
this.place = place;
}
public String getManager() {
return manager;
}
public void setManager(String manager) {
this.manager = manager;
}
public Integer getBedCount() {
return bedCount;
}
public void setBedCount(Integer bedCount) {
this.bedCount = bedCount;
}
public Integer getTableCount() {
return tableCount;
}
public void setTableCount(Integer tableCount) {
this.tableCount = tableCount;
}
public ListPerson getPersons() {
return persons;
}
public void setPersons(ListPerson persons) {
this.persons = persons;
}
public char getSexFlag() {
return sexFlag;
}
public void setSexFlag(char sexFlag) {
this.sexFlag = sexFlag;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Bedroom bedroom = (Bedroom) o;
return sexFlag == bedroom.sexFlag
Objects.equals(place, bedroom.place)
Objects.equals(manager, bedroom.manager)
Objects.equals(bedCount, bedroom.bedCount)
Objects.equals(tableCount, bedroom.tableCount)
Objects.equals(persons, bedroom.persons);
}
@Override
public int hashCode() {
return Objects.hash(place, manager, bedCount, tableCount, persons, sexFlag);
}
@Override
public String toString() {
return "Bedroom{" +
"place='" + place + '\'' +
", manager='" + manager + '\'' +
", bedCount=" + bedCount +
", tableCount=" + tableCount +
", persons=" + persons +
", sexFlag=" + sexFlag +
'}';
}
}
寝室中住宿的人员类如下:
import java.util.Objects;
public class Person {
private String sno;
private String name;
private String subject;
public String getSno() {
return sno;
}
public void setSno(String sno) {
this.sno = sno;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
return Objects.equals(sno, person.sno)
Objects.equals(name, person.name)
Objects.equals(subject, person.subject);
}
@Override
public int hashCode() {
return Objects.hash(sno, name, subject);
}
@Override
public String toString() {
return "Person{" +
"sno='" + sno + '\'' +
", name='" + name + '\'' +
", subject='" + subject + '\'' +
'}';
}
}
求一份Java 学生宿舍管理系统,有源码,求大神,先谢啦
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
public class MainFrame extends JFrame implements ActionListener{
InsertPanel ip = null;
SelectPanel sp = null;
JPanel pframe;
JButton jb1,jb2,jb3;
JMenuItem jm11,jm21,jm22,jm23,jm31,jm32,jm41,jm42;
CardLayout clayout;
public MainFrame(String s){
super(s);
JMenuBar mb = new JMenuBar();
this.setJMenuBar(mb);
JMenu m1 = new JMenu("系统");
JMenu m2 = new JMenu("基本信息");
JMenu m3 = new JMenu("成绩");
JMenu m4 = new JMenu("奖惩");
mb.add(m1);
mb.add(m2);
mb.add(m3);
mb.add(m4);
jm11 = new JMenuItem("退出系统");
jm21 = new JMenuItem("输入");
jm22 = new JMenuItem("查询");
jm23 = new JMenuItem("更改");
jm31 = new JMenuItem("输入成绩");
jm32 = new JMenuItem("查询成绩");
jm41 = new JMenuItem("奖励");
jm42 = new JMenuItem("处分");
m1.add(jm11);
m2.add(jm21);
m2.add(jm22);
m2.add(jm23);
m3.add(jm31);
m3.add(jm32);
m4.add(jm41);
m4.add(jm42);
Icon i1 = new ImageIcon();
Icon i2 = new ImageIcon();
Icon i3 = new ImageIcon();
jb1 = new JButton(i1);
jb1.setToolTipText("输入");
jb2 = new JButton(i2);
jb2.setToolTipText("查询");
jb3 = new JButton(i3);
jb3.setToolTipText("退出");
JToolBar tb = new JToolBar("系统工具");
tb.add(jb1);
tb.add(jb2);
tb.add(jb3);
add(tb,BorderLayout.NORTH);
jm11.addActionListener(this);
jm21.addActionListener(this);
jm22.addActionListener(this);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
clayout = new CardLayout();
pframe = new JPanel(clayout);
add(pframe);
JPanel mainp = new JPanel(new BorderLayout());
JLabel mainl = new JLabel("学生信息管理平台",SwingConstants.CENTER);
mainl.setFont(new Font("serif",Font.BOLD,30));
mainp.add(mainl);
pframe.add(mainp,"main");
clayout.show(pframe, "main");
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jm21 || e.getSource() == jb1){
if(ip == null){
ip= new InsertPanel();
pframe.add(ip,"insert");
}
clayout.show(pframe, "insert");
this.setTitle("输入学生信息");
}
else if(e.getSource() == jm22 || e.getSource() == jb2){
if(sp == null){
sp= new SelectPanel();
pframe.add(sp,"select");
}
clayout.show(pframe, "select");
this.setTitle("查询学生信息");
}
else if(e.getSource() == jm11 || e.getSource() == jb3){
System.exit(0);
}
}
}
第二个:
import javax.swing.JFrame;
public class MainTest {
public static void main(String [] args){
MainFrame f = new MainFrame("学生信息管理平台");
f.setSize(400,300);
f.setLocation(350,250);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
第二个:
import java.sql.Connection;
import java.sql.DriverManager;
public class MySQLConnection {
static Connection getCon(){
Connection con = null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","123");
}
catch(Exception e){
System.out.println("建立数据库连接遇到异常!");
}
return con;
}
}
第四个:
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class SelectPanel extends JPanel implements ActionListener{
JButton jb;
JTextField jt;
JTextField jt1,jt2,jt3,jt4;
public SelectPanel(){
JLabel jl = new JLabel("请输入学号:",SwingConstants.CENTER);
jt = new JTextField();
jb = new JButton("确定");
JPanel jp1 = new JPanel(new GridLayout(1,3));
jp1.add(jl);
jp1.add(jt);
jp1.add(jb);
JLabel j1,j2,j3,j4;
j1 = new JLabel("学号:",SwingConstants.CENTER);
j2 = new JLabel("姓名:",SwingConstants.CENTER);
j3 = new JLabel("性别:",SwingConstants.CENTER);
j4 = new JLabel("年龄:",SwingConstants.CENTER);
jt1 = new JTextField(6);
jt1.setEditable(false);
jt2 = new JTextField(6);
jt2.setEditable(false);
jt3 = new JTextField(6);
jt3.setEditable(false);
jt4 = new JTextField(6);
jt4.setEditable(false);
JPanel jp2 = new JPanel(new BorderLayout());
JPanel jp3 = new JPanel(new GridLayout(4,2));
jp2.add(new JLabel(""),BorderLayout.NORTH);
jp3.add(j1);
jp3.add(jt1);
jp3.add(j2);
jp3.add(jt2);
jp3.add(j3);
jp3.add(jt3);
jp3.add(j4);
jp3.add(jt4);
jp2.add(jp3);
this.setLayout(new BorderLayout());
add(jp1,BorderLayout.NORTH);
add(jp2);
jb.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jb){
String stuNo = jt.getText().trim();
Student s = new Student();
boolean b = true;
try{
b = s.selectByStuNo(stuNo);
}
catch(Exception ex){
System.out.println("查询学生信息遇到异常!");
}
if(b){
jt1.setText(s.getStuNo());
jt2.setText(s.getName());
jt3.setText(s.getGender());
int a = s.getAge();
Integer i = new Integer(a);
jt4.setText(i.toString());
}
else{
JOptionPane.showMessageDialog(null, "无此学生!");
}
}
}
}
为宿舍管理人员编写一个宿舍管理查询软件, 程序采用交互工作方式,
基本上就是这样了。。。只有输出输入用了c++的cout/cin你可以自己换成printf和scanf,很简单的。。
程序在vc下运行了。
#includeiostream.h
#includestring.h
#includestdio.h
#includestdlib.h
struct student{
char ID[10];//学号
int BN;//床号
char RN[10];//宿舍号
char NAME[10];//姓名
student *next;
};
typedef student stu;
stu* Head;
int menu()//用户选择的菜单
{
cout"1:查看学生信息"endl;
cout"2按学号排序:"endl;
cout"3:查看宿舍的人员信息"endl;
cout"0:退出系统"endl;
cout"请选择"":";
char c;
int ch;
int flag=1;
while(flag)
{
cinc;
ch=(int)c-48;
if(ch=0ch=3)
flag=0;
else
cout"输入错误,请重新输入:";
}
return ch;
}
void sort(stu *head)//冒泡排序
{ int time=0;
char id[10];
int bn;
char rn[10];
char name[10];
stu* temp=head;
while(temp-next!=NULL)
{
temp=temp-next;
time++;
}
temp=head;
int i,j,last;
i=time-1;while(i0){
for(j=0;ji;j++)
{
if(temp-BNtemp-next-BN)
{
strcpy(id,temp-ID);
strcpy(rn,temp-RN);
strcpy(name,temp-NAME);
bn=temp-BN;
strcpy(temp-ID,temp-next-ID);
strcpy(temp-RN,temp-next-RN);
strcpy(temp-NAME,temp-next-NAME);
temp-BN=temp-next-BN;
strcpy(temp-next-ID,temp-ID);
strcpy(temp-next-RN,temp-RN);
strcpy(temp-next-NAME,temp-NAME);
temp-next-BN=temp-BN;
last=j;
}
i=last;
}
}
cout"排序成功!!!"endl;
}
void List(stu *head) // 打印所有学生信息
{
stu *p;
p=head;
if(p==NULL)
cout"记录为空"endl;
else
{ cout"记录如下:"endl;
while(p!=NULL){
coutp-ID" "p-BN" "p-RN" "p-NAMEendl;
p=p-next;
}
}
}
stu *InputNewRecord(stu *node)//输入新加成员的信息
{
cout"Input ID\n";
cinnode-ID;
cout"Input BN\n";
cinnode-BN;
cout"Input RN\n";
cinnode-RN;
cout"Input NAME\n";
cinnode-NAME;
return node;
}
int OkOrNot(char *name)
{
char c;
cout"请确认想进行此项操作(是请按y或者Y)";
cinc;
if(c=='y'||c=='Y')
return 1;
else
return 0;
}
void AppendNode(stu *head)/*在链表的末尾添加新的节点*/
{
stu *p,*newnode,*last;
if(!OkOrNot("Append")) return;
last=head;
p=head-next;
while(p!=NULL)
{
last=p;
p=p-next;
}
newnode=(stu*)malloc(sizeof(stu));
newnode-next=NULL;
p=InputNewRecord(newnode);
last-next=p;
}
void ShowRD(stu *head)//查找某宿舍的学生信息
{
stu *p=head;
int flag=1;
cout"输入你要查看的房间号:"endl;
char tp[10];
gets(tp);
for(;p!=NULL;p=p-next)
{
if(strcmp(p-RN,tp)==0)//找到并打印
{
coutp-ID"**"p-BN"**"p-RN"**"p-NAMEendl;
flag=0;
}
}
if(flag)
}
int main()
{
stu a=;
stu *head;
head=a;
head-next=NULL;
Head=head;
cout" 欢迎进入宿舍信息管理系统 "endl;
cout" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "endl;
begin: AppendNode( Head);
cout"还要输吗?"endl;
char k;
cink;
if(k=='Y'||k=='y')
goto begin;
int f3=1;
while(f3)
{
switch(menu())
{
case 1:
List(Head);
break;
case 2:
sort(Head);
break;
case 3:
ShowRD(Head);
break;
case 0:
f3=0;
break;
}
}
return 0;
}
java语言编写的学生宿舍管理系统
也不是难啊!关键是麻烦啊!你看看你要的差不多就一个项目了啊!还要建表啊!用数据库啊!我这有一个图书管理系统啊!是jcreat做的啊!你那个就是实现了增删改差啊!基本功能,不过麻烦啊!你要是局部的不是先帮助还行啊!
本文题目:查询宿舍信息java代码 查询宿舍信息java代码是什么
浏览路径:http://myzitong.com/article/dodesdj.html