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

📄 mainprogvideostore.java

📁 这是有关java的应用 通过事例对java数据结构的链表的应用
💻 JAVA
字号:
/*
 * mainProgVideoStore.java
 *
 * Created on 2007年3月17日, 下午2:17
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package 音像店;
import java.io.*;
public class mainProgVideoStore
{  
  static BufferedReader keyboard=new  BufferedReader(new InputStreamReader(System.in));
    public mainProgVideoStore()
    { }
    public static void main(String []args)
    {
        VideoList videoList=new VideoList();
        int choice;
        String title; 
        try
        {
            BufferedReader infile=new BufferedReader(new FileReader("F:\\音像店\\src\\音像店\\videoDat.txt"));
            createVideoList(infile,videoList);
            displyMenu();
            System.out.println("Enter your choice:");
            choice=Integer.parseInt(keyboard.readLine());
            System.out.println();
            while(choice !=9)
            {
                switch(choice)
                {
                    case 1:System.out.println("Enter the title:");
                             title=keyboard.readLine();
                             System.out.println();
                             if(videoList.videoSearch(title))System.out.println("Title found.");
                             else    System.out.println("Video not in store.");
                             break;
                    case 2:System.out.println("Enter the title:");
                           title=keyboard.readLine();
                           System.out.println();
                           if(videoList.videoSearch(title))
                           {
                               if(videoList.isVideoAvailable(title))
                               {
                                   videoList.videoCheckOut(title);
                                    System.out.println("Enjoy your movie: "+ title);
                               }
                               else     System.out.println("Currently"+ title + "is out of store.");
                                   
                               System.out.println("Title found.");
                           }
                           else    System.out.println("the store does not  carry " + title);
                           break;       
                   case 3: System.out.println("Enter the title:");
                           title=keyboard.readLine();
                           System.out.println();
                           if(videoList.videoSearch(title))
                           {
                             videoList.videoCheckIn(title);
                             System.out.println("Thanks for retuning "+ title);  
                           }
                           else System.out.println("This video does not from our store."); 
                          break;
                  case 4: System.out.println("Enter the title:");
                           title=keyboard.readLine();
                           System.out.println();
                           if(videoList.videoSearch(title))
                           {
                               if(videoList.isVideoAvailable(title)) 
                                   System.out.println(title + "is currently in store");
                               else                             
                                   System.out.println(title + "is out of store");  
                           }
                           else 
                               System.out.println(title + "is not from our store"); 
                          break;   
                  case 5: videoList.videoPrintTitle();
                          break;
                  case 6: System.out.println(videoList);
                          break;
                  default:System.out.println("Invalid Selection"); 
                }//end swicth
                displyMenu();
                System.out.println("Enter your choice:");
                choice=Integer.parseInt(keyboard.readLine());
                System.out.println();
            }//end while   
        
        } 
        catch(FileNotFoundException fnfe)
        {
            System.out.println(fnfe.toString());
        }
        catch(IOException ioe)
        {
            System.out.println(ioe.toString());
        }
    }
    public static void createVideoList(BufferedReader infile,VideoList videoList) throws IOException
    {
        
        String Title;
        String Star1;
        String Star2;
        String Producer;
        String Director;
        String ProductionCo;
        int InStock;
        VideoElement newVideo=new VideoElement();
        Title=infile.readLine();
        while(Title !=null)
        { 
            Star1=infile.readLine();
            Star2=infile.readLine();
            Producer=infile.readLine();
            Director=infile.readLine();
            ProductionCo=infile.readLine();
            InStock=Integer.parseInt(infile.readLine());
            newVideo.setVideoInfo(Title,Star1,Star2,Producer,Director,ProductionCo,InStock);
            videoList.insertFirst(newVideo);
            Title=infile.readLine();
        }
    }
    public static void displyMenu()
    {
       System.out.println("请选择标号:"); 
       System.out.println("1:To check whether a particular video is in the store"); 
       System.out.println("2:To check out a video"); 
       System.out.println("3:To check in a video"); 
       System.out.println("4:To check whether a particular title is in the store"); 
       System.out.println("5:To print the titles of all the videos"); 
       System.out.println("6:To print a list of all the videos");
       System.out.println("9:To exit"); 
    }
    }

⌨️ 快捷键说明

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