Adding new curriculum

(1) new course information must be unique, if repeated, prompts the user to "repeat the course name, re-entry";

(2) requires a determination of teachers Wang, Liu Lijia, Dan, Hui, Yang Zaiguang wherein five teachers.

(3) the beginning of the Venue claim one for the "a teaching, teach two, three teaching, teaching group" in;

(4) add new course information storage.

package Curriculum;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;

import javax.swing.JOptionPane;

public class Curriculum 
{
    public static String[] readFile()
    {
        int i=0;
        String pathname="课程.txt";
        String[] m=new String[26];
        try
        (
                FileReader reader=new FileReader(pathname);
                BufferedReader br=new BufferedReader(reader)
        )
        {
            String d;
            while((d=br.readLine())!=null)
            {
                m[i]=d;
                i++;
            }
        }
        catch(IOException e)
        {
            e.printStackTrace (); 
        } 
        return m; 
    } 
    public  static  void main (String [] args) 
    { 
        String [] Line = readFile (); 
        String A1 = "Wang", a2 = "Liu Lijia", a3 = "Dan" , a4 = "Hui", a5 = "Yang Zaiguang" ; 
        String B1 = "a teach *", b2 = "teach two *", b3 = "three teach *", b4 = "group teach *" ; 
        String imput1, imput2 , imput3; 
        for ( int I = 0 ;; I ++ ) 
        { 
            imput1 = JOptionPane.showInputDialog ( "course name:" );
            int sign=1;
            for(int j=0;j<line.length;j++)
            {
                String[] words=line[i].split("/");
                if(imput1.equals(words[0]))
                {
                    sign=0;
                    break;
                }
            }
            if(sign==1);
            {
                JOptionPane.showMessageDialog(null, "录入成功,请继续录入。");
                break;
            }
            else
            {
                JOptionPane.showMessageDialog(null , imput1 + "already exists, please re-enter." ); 
            } 
        } 
        for ( int J = 0 ;; J ++ ) 
        { 
            imput2 = JOptionPane.showInputDialog ( "instructor:" );
             IF (a1.equals (imput2) || 
               a2.equals (imput2) || 
               a3.equals (imput2) || 
               a4.equals (imput2) || 
               a5.equals (imput2)) 
            { 
                JOptionPane.showMessageDialog ( null , "entry is successful, continue entering." );
                 BREAK ; 
            } 
            the else
            { 
                JOptionPane.showMessageDialog ( null , "No instructor:" + imput2 + ", please re-enter." ); 
            } 
        } 
        For ( int K ++ K = 0 ;; ) 
        { 
            imput3 = JOptionPane.showInputDialog ( "Venue:" );
             IF (b1.equals (imput3) || 
               b2.equals (imput3) || 
               b3.equals (imput3) || 
               b4.equals (imput3)) 
            { 
                JOptionPane.showMessageDialog ( null , "to complete the entry." );
                 BREAK ; 
            }
            else
            {
                JOptionPane.showMessageDialog(null, "没有上课地点:"+imput3+",请重新录入。");
            }
        }
        PrintWriter wi=new PrintWriter(new OutputStreamWriter(new FileOutputStream("file.txt"),"gbk"));
        wi.println(imput1+"/"+imput2+"/"+imput3+"/");
        wi.close();
        BufferedReader re=new BufferedReader(new InputStreamReader(new FileInputStream("file.txt"),"gbk"));
        String ss=null;
        if((ss=re.readLine())!=null)
        {
        System.out.println(ss);
        }
        re.close();
    }            
}

 

Guess you like

Origin www.cnblogs.com/zql-42/p/11708113.html