⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createlevelsquentialfile.java

📁 一个飞机调度员模拟训练程序,可以添加跑道数量,控制飞机飞行的速度.默认的密码可以在AtcSystem类里面修改,其中内置了三个用户名.这套系统是我和几个国外同学合力开发的,希望对大家有帮助
💻 JAVA
字号:
import java.io.*;
import java.util.*;

public class CreateLevelSquentialFile
{
    // instance variables 
    private ObjectOutputStream output;  // output data to file
    private String fileName;
    Level level; // object to be written to file
    String levelName;
    String description;
    int runway;
    float frequency;
    int numCrafts;
         
    /**
     * Constructor for objects of class CreateSquentialFile
     */
    public CreateLevelSquentialFile(String levelName, String description,  int runway, float frequency, int numCrafts)
    {
        // initialise instance variables
        this.levelName = this.fileName  = levelName;
        this.description = description;
        this.runway      = runway;
        this.frequency   = frequency;
        this.numCrafts   = numCrafts;
    
    }
    
    
    public void openFile()
    {
        try //open file
        {
            output = new ObjectOutputStream(new FileOutputStream("H:\\" + getFileName() + ".lvl"));
        }  // end try
        
        catch(IOException ioException)
        {
            System.err.println("Error opening file");
        }
        
     }
        
     public void setFileName(String f)
     {
         fileName = f;
     }
     
     public String getFileName()
     {
         return fileName;
     }
     
     public void addUserRecord()
     {
         
         try
         {
       
            level = new Level(levelName, description,  runway,frequency, numCrafts);
            output.writeObject(level); // write to file
        }
        catch (IOException ioException)
        {
            System.err.println("Error writing to file " + ioException.getMessage());
            return;
        }
     } // end add records
         
     public void closeFile()
     {
         try
         {
             if (output != null) 
             output.close();
         }
         
         catch (IOException ioExeception)
         {
             System.err.println("Error closing file");
             System.exit(1);
        }
    }
     
    public String getLevelName()
    {
        return levelName;
    }
    
    public String getDescription()
    {
        return description;
    }
    
    public int getRunways()
    {
        return runway;
    }
    
    public float getFrequency()
    {
        return frequency;
    }
    
    
   public int getNumcrafts()
    {
        return numCrafts;
    }
} // end class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -