<file_sep>

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;


public class Admistrator_CheckUser extends JFrame implements ActionListener {

	public JButton check, back;
	public JLabel id_label;
	public JTextField id_text;
	JPanel panel1,panel2;
	String idBuffer;
	Object[] options= {"OK"};

	public Admistrator_CheckUser() {
		Container c = this.getContentPane();
		panel1=new JPanel();
		//panel1.setPreferredSize(new Dimension(400, 600));
		//panel1.setSize(15,20);
		id_label = new JLabel("ID Numer:");
		panel1.add(id_label);
		id_text=new JTextField(8);
		panel1.add(id_text);


		panel2=new JPanel();
		//panel2.setPreferredSize(new Dimension(1, 1));
		//panel2.setSize(1,1);
		check=new JButton("Check");
		check.addActionListener(this);
		panel2.add(check);
		back=new JButton("Back");
		back.addActionListener(this);
		panel2.add(back);

		c.add(panel1,BorderLayout.CENTER);
		c.add(panel2,BorderLayout.SOUTH);



		this.setTitle("Administrator");
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
	}
	public void actionPerformed(ActionEvent e) {
		JButton eventSource = (JButton) e.getSource();
		if (eventSource == check)
		{
			if(id_text.getText().isEmpty())//check whether input is empty
			{
				JOptionPane.showOptionDialog(null,"You information is not fill out completely","Please enter again",JOptionPane.DEFAULT_OPTION,
						JOptionPane.WARNING_MESSAGE,null,options,options[0]);
			}
			/*else if ()//check input format
			{
				JOptionPane.showOptionDialog(null,"You input format is incorrect","Please enter again",JOptionPane.DEFAULT_OPTION,
						JOptionPane.WARNING_MESSAGE,null,options,options[0]);
			}
			*/
			/*else if ()//check if the user ID is in database
			{
				JOptionPane.showOptionDialog(null,"The user's ID is not in the database","Please enter again",JOptionPane.DEFAULT_OPTION,
						JOptionPane.WARNING_MESSAGE,null,options,options[0]);
			}
			*/
			else {
				idBuffer=id_text.getText();
				System.out.println("idBuffer="+idBuffer);
				Admistrator_UserReport UserReport = new Admistrator_UserReport();//为跳转的界面
				UserReport.pack();
				UserReport.setSize(300, 200);
				UserReport.setLocationRelativeTo(null);
				UserReport.setVisible(true);
				this.dispose();//销毁当前界面

			}

		}
		else if (eventSource == back)
		{
			Admistrator_main main = new Admistrator_main();//为跳转的界面
			main.pack();
			main.setSize(300, 200);
			main.setLocationRelativeTo(null);
			main.setVisible(true);
			this.dispose();//销毁当前界面
		}

	}




}
<file_sep>import java.io.Serializable;

public class Student implements Serializable{

  private String QMNum="161194886";
  private String name;
  private String email;
  private int currentTime=0;
  private int totalTime=0;
  private boolean differentDay=false;
  private int dataMonth=0;
  private int dataDay=0;

  public Student(){

  }

  public Student(String QMNum, String name, String email){
    this.QMNum=QMNum;
    this.name=name;
    this.email=email;
  }

  public void setQMNum(String QMNum){
    this.QMNum=QMNum;
  }

  public String getQMNum(){
    return this.QMNum;
  }

  public void setStudentName(String name){
    this.name=name;
  }

  public String getStudentName(){
    return this.name;
  }

  public void setEmail(String email){
    this.email=email;
  }

  public String getEmail(){
    return this.email;
  }

  public void setCurrentTime(int currentTime){
    this.currentTime=currentTime;
  }

  public int getCurrentTime(){
    return this.currentTime;
  }

  public void setTotalTime(int totalTime){
    this.totalTime=totalTime;
  }

  public int getTotalTime(){
    return this.totalTime;
  }

  public void setDifferentDay(boolean differentDay){
    this.differentDay=differentDay;
  }

  public boolean getDifferentDay(){
    return this.differentDay;
  }

  public boolean getDifferentDay(int dataMonth, int dataDay){
    if(this.dataMonth==dataMonth  &&  this.dataDay==dataDay)
      return false;
    else
      return true;
  }

  public void setDataMonth(int dataMonth){
    this.dataMonth=dataMonth;
  }

  public int getDataMonth(){
    return this.dataMonth;
  }

  public void setDataDay(int dataDay){
    this.dataDay=dataDay;
  }

  public int getDataDay(){
    return this.dataDay;
  }
}
<file_sep>import java.io.IOException;
import java.io.*;
import java.io.Serializable;
import java.io.OutputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.util.Calendar;

public class IOTest{

public static ParkingLot QM=new ParkingLot(8,8,8);
public static ParkingLot QM1=new ParkingLot(); //用于传递qm 操作时对qm1操作

public static Calendar calendar=Calendar.getInstance();
public static int month =calendar.get(Calendar.MONTH);
public static int date =calendar.get(Calendar.DATE);
public static int hour = calendar.get(Calendar.HOUR_OF_DAY);
public static int minute = calendar.get(Calendar.MINUTE);
public static int time=((month*30+date)*24+hour)*60+minute;

public static Student student= new Student("161194886","<NAME>","<EMAIL>");
public static Student student1=new Student();



   public static void getStudentDataFromChart(){
     student1.setQMNum("161194886");
     student1.setStudentName("<NAME>");
     student1.setEmail("<EMAIL>");
   }



   public static void studentInput() throws IOException,ClassNotFoundException{

     try{
     File file1=new File("/Users/dongzeyuan1/Desktop/"+student1.getQMNum());
     FileInputStream fis1= new FileInputStream(file1);
     ObjectInputStream iis1= new ObjectInputStream(fis1);

     Student student=(Student)iis1.readObject();
     iis1.close();
     System.out.println(student.getQMNum());
     System.out.println(student.getStudentName());
     System.out.println(student.getEmail());
     System.out.println(student.getCurrentTime());
     System.out.println(student.getTotalTime());
     System.out.println(student.getDifferentDay());
     student1=student;
   }catch(IOException e){
  //   File file1=new File("/Users/dongzeyuan1/Desktop/"+student1.getQMNum());
  //   file1.createNewFile();
  //   System.out.println("The txt file "+student1.getQMNum()+".txt is created!");
     e.printStackTrace();
    }
   }




   public static void studentOutput(){
     student=student1;

     try{
       FileOutputStream fos1= new FileOutputStream(new File("/Users/dongzeyuan1/Desktop/"+student1.getQMNum()));
      ObjectOutputStream oos1;
      oos1=new ObjectOutputStream(fos1);
      oos1.writeObject(student);
      oos1.close();
    }catch(IOException e){
      e.printStackTrace();
    }
   }




   public static void output(){
    // ParkingLot QM1=new ParkingLot(8,8,8); //该行用于重置
    //QM1.takeBikeFromA();
    //QM1.returnBikeToB();
    //QM1.getBikeOnTheWay();
      QM=QM1;

      try{
        FileOutputStream fos= new FileOutputStream(new File("/Users/dongzeyuan1/Desktop/Database"));
       ObjectOutputStream oos;
       oos=new ObjectOutputStream(fos);
       oos.writeObject(QM);
       oos.close();
     }catch(IOException e){
       e.printStackTrace();
     }
   }







   public static void input()throws IOException,ClassNotFoundException{
     try{
     File file=new File("/Users/dongzeyuan1/Desktop/Database");
     FileInputStream fis= new FileInputStream(file);
     ObjectInputStream iis= new ObjectInputStream(fis);

     ParkingLot QM=(ParkingLot)iis.readObject();
     iis.close();
     //System.out.println(QM.getBikeInA());
     //System.out.println(QM.getBikeInB());
     //System.out.println(QM.getBikeOnTheWay());
     QM1=QM;
   }catch(IOException e){
     e.printStackTrace();
   }
}




//从A地借车，并储存借车信息。成功借车返回1，A地无车返回0，输入为QMNum的字符串
  public static int borrowBikeFromA(){
    try{
      input();
    }catch(ClassNotFoundException | IOException e){
    e.printStackTrace();
    }

    if(QM1.getBikeInA()<=0){
      return 0;
    }
    else{
      QM1.takeBikeFromA();
      output();
      getStudentDataFromChart();
      try{
        studentInput();
      }catch(ClassNotFoundException | IOException e){
      e.printStackTrace();
      }
      student1.setCurrentTime(time);

      if(student1.getDifferentDay(month,date)==false){

      }
      else{
        student1.setDataMonth(month);
        student1.setDataDay(date);
        student1.setTotalTime(0);
      }
      studentOutput();
      return 1;
    }
  }








  public static void main(String args[])throws IOException{
    /*
    try{
     input();
    }catch(ClassNotFoundException e){
      e.printStackTrace();
    }

    output();
    */



  /*  try{
    input();
    }catch(ClassNotFoundException e){
    e.printStackTrace();
    }
    */
    int a;

    a=borrowBikeFromA();

    System.out.println( month+" "+date+" "+hour+" "+minute+" "+time);



    try{
      studentInput();
      }catch(ClassNotFoundException e){
    e.printStackTrace();
    }

    System.out.println(student1.getDifferentDay());
    System.out.println(student1.getCurrentTime());
    System.out.println(student1.getTotalTime());
    System.out.println(student1.getDataMonth());
    System.out.println(student1.getDataDay());
    System.out.println(QM1.getBikeInA());
    System.out.println(a);

  }
}
<file_sep>
import java.io.IOException;
import java.io.*;
import java.io.Serializable;
import java.io.OutputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.util.Calendar;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;


public class Admistrator_Register extends JFrame implements ActionListener {
	public JButton register, back;
	public JLabel id_label,name_label,email_label;
	public JTextField id_text,name_text,email_text;
	JPanel panel1,panel2,panel3,panel4,panel5,panel6,panel7;
	private String idBuffer,nameBuffer,emailBuffer;
	Object[] options= {"OK"};


	public Admistrator_Register() {
		Container c = this.getContentPane();
		c.setLayout(new BorderLayout());

		panel1=new JPanel();
		//panel1.setPreferredSize(new Dimension(400, 600));
		//panel1.setSize(15,20);
		panel1.setLayout(new GridLayout(4,2,10,10));
		id_label = new JLabel("ID Numer:");
		panel1.add(id_label);
		id_text=new JTextField(8);
		panel1.add(id_text);
		name_label = new JLabel("      Name:");
		panel1.add(name_label);
		name_text=new JTextField(8);
		panel1.add(name_text);
		email_label = new JLabel("      Email:");
		panel1.add(email_label);
		email_text=new JTextField(8);
		panel1.add(email_text);

		//panel2=new JPanel();

		//panel2.setPreferredSize(new Dimension(1, 1));
		//panel2.setSize(1,1);
		register=new JButton("Register");
		register.addActionListener(this);
		panel1.add(register);
		back=new JButton("Back");
		back.addActionListener(this);
		panel1.add(back);
		//panel2.setLayout(new GridLayout(0,2,10,10));

		//panel7=new JPanel();
		//panel7.add(panel1);
		//panel7.add(panel2);
		//panel7.setLayout(new GridLayout(2,1,10,10));

		panel3=new JPanel();
		panel4=new JPanel();
		panel5=new JPanel();
		panel6=new JPanel();
		c.add(panel1,BorderLayout.CENTER);
		c.add(panel6,BorderLayout.SOUTH);
		c.add(panel3,BorderLayout.WEST);
		c.add(panel4,BorderLayout.EAST);
		c.add(panel5,BorderLayout.NORTH);


		this.setTitle("Administrator");
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
	}
	public void actionPerformed(ActionEvent e) {

		JButton eventSource = (JButton) e.getSource();
		if (eventSource == register)
		{
			if(id_text.getText().isEmpty()||name_text.getText().isEmpty()||email_text.getText().isEmpty())//check whether input is empty
			{
				JOptionPane.showOptionDialog(null,"You information is not fill out completely","Please enter again",JOptionPane.DEFAULT_OPTION,
						JOptionPane.WARNING_MESSAGE,null,options,options[0]);
			}
			/*else if ()//check input format
			{
				JOptionPane.showOptionDialog(null,"You input format is incorrect","Please enter again",JOptionPane.DEFAULT_OPTION,
						JOptionPane.WARNING_MESSAGE,null,options,options[0]);
			}
			*/
			/*else if ()//check if the user ID is in database
			{
				JOptionPane.showOptionDialog(null,"Your information has met the requirements","Keep going",JOptionPane.DEFAULT_OPTION,
						JOptionPane.INFORMATION_MESSAGE,null,options,options[0]);
			}
			*/
			else {
				idBuffer=id_text.getText();
				nameBuffer=name_text.getText();
				emailBuffer=email_text.getText();
				IOTest.student1.setQMNum(idBuffer);
				IOTest.student1.setStudentName(nameBuffer);
				IOTest.student1.setEmail(emailBuffer);
				IOTest.studentOutput();
				System.out.println("idBuffer="+idBuffer);
				System.out.println("nameBuffer="+nameBuffer);
				System.out.println("emailBuffer="+emailBuffer);
				/*
				try{
					IOTest.studentInput();
				}catch(ClassNotFoundException | IOException ex){
				ex.printStackTrace();
				}
				System.out.println(IOTest.student1.getQMNum());
				System.out.println(IOTest.student1.getStudentName());
				System.out.println(IOTest.student1.getEmail());
				System.out.println(IOTest.student1.getCurrentTime());
				System.out.println(IOTest.student1.getTotalTime());
				System.out.println(IOTest.student1.getDifferentDay());
				System.out.println(IOTest.student1.getDataMonth());
				System.out.println(IOTest.student1.getDataDay());
				*/
				//Sucessfully log in (JOptionPane)

			}

		}
		else if (eventSource == back)
		{
			Admistrator_main main = new Admistrator_main();//为跳转的界面
			main.pack();
			main.setSize(300, 200);
			main.setLocationRelativeTo(null);
			main.setVisible(true);
			this.dispose();

		}




	}

/*
	public static void main(String[] args) {
		Admistrator_Register myDemo = new Admistrator_Register();
		myDemo.pack();
		myDemo.setVisible(true);
	}
*/
}
