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

📄 videolist.java

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


package 音像店;

/**
 *
 * @author Administrator
 */
public class VideoList extends UnorderedLinkedList{
    private  LinkedListNode searchVideoList(String title)
    {
        boolean found=false;
        LinkedListNode current=null;
        VideoElement temp=new VideoElement();
        if(first==null)System.out.print("Cannot search an empty list.");
        else
        {
            current=first;
            found=false;
            while(current !=null && !found)
            {
                temp=( VideoElement)current.info;
                if(temp.checkTitle(title)) found=true;
                else
                    current=current.link;
            }
        }
             return current;
   }
    public boolean videoSearch(String title)
    {
        LinkedListNode location;
        location=searchVideoList(title);
        return(location !=null);
    }
    public boolean isVideoAvailable(String title)
    {
        LinkedListNode location;
        VideoElement temp; 
        location=searchVideoList(title);
        if(location !=null)
        {
            temp=(VideoElement)location.info;
             return(temp.getNoOfCopiesInStock()>0); 
        }
        else 
           return false;
    }
    public void videoCheckIn(String title)//输入电影到链表
    {
        LinkedListNode location;
        VideoElement temp; 
        location=searchVideoList(title);
        if(location !=null)
        {
            temp=(VideoElement)location.info;
             temp.checkIn();
        }
        else
            System.out.println("The store does not carry this video.");    
    }
    public void videoCheckOut(String title)//注销电影
    {
        LinkedListNode location;
        VideoElement temp; 
        location=searchVideoList(title);
        if(location !=null)
        {
            temp=(VideoElement)location.info;
             temp.checkOut();
        }
        else
            System.out.println("The store does not carry this video.");    
    }
    public boolean videoCheckTitle(String title)//搜索,是否存在此电影
    {
        LinkedListNode location;
        location=searchVideoList(title); 
        return(location !=null);
    }
    public void videoUpdateStock(String title,int num)//修改同种电影的数目
    {
        LinkedListNode location;
        VideoElement temp;
        location=searchVideoList(title); 
        if(location !=null)
        {
            temp=(VideoElement)location.info;
            temp.updateInStock(num);
        }
        else
            System.out.println("The store does not carry this video.");    
    }
    public void videoSetCopiesInStock(String title,int num)//设置同种电影的数目
    {
        LinkedListNode location;
        VideoElement temp;
        location=searchVideoList(title); 
        if(location !=null)
        {
            temp=(VideoElement)location.info;
            temp.setCopiesInStock(num);
        }
        else
            System.out.println("The store does not carry this video.");     
    }
    public void videoPrintTitle()
    {
       LinkedListNode current;
       VideoElement temp;
       current=first; 
       while(current !=null)
       {
           temp=(VideoElement)current.info;
           temp.printTitle();
           current=current.link;
       }
    }
    public void print()
    {
       LinkedListNode current;
       VideoElement temp;
       current=first; 
       while(current !=null)
       {
           temp=(VideoElement)current.info;
           temp.printInfo();
           current=current.link;
       }
    }
    public VideoList()
    {
        super();
    }
    public VideoList(VideoList otherList)
    {
        super(otherList);
    }
}

⌨️ 快捷键说明

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