#PTAOOP525. 5-25 学位论文

5-25 学位论文

本站提交说明

此题属于 面向对象程序设计练习。请在练习页填写原题的填空或函数片段并提交;本题独立提交页接收拼接后的完整 Java 程序。

评测使用题面样例与本站补充测试,包含编译、输出及部分成员 API 检查。通过本站测试不代表通过 PTA 隐藏测试。

编写一个接口References和两个类Paper和Dissertation。

(1)编写一个接口References表示参考文献,包含以下成员
①方法:

  1. String reference(),返回参考文献的引文格式。

(2)编写一个Paper类表示论文,包含以下成员

①属性:

  1. title:私有,String型,表示论文标题。

  2. author:私有,String型,表示论文作者。

②方法:

  1. Paper(String title, String author),构造方法,用参数分别初始化标题和作者;

  2. 为title和author添加getter和setter方法。

(3)编写一个Paper类的子类Dissertation,表示学位论文。Dissertation类实现了References接口。Dissertation类包含以下成员
①属性:

  1. city:私有,String型,表示城市。

  2. school:私有,String型,表示学校。

  3. year:私有,int型,表示发表年份。

②方法:

  1. Dissertation(String title, String author, String city, String school, int year),构造方法,用参数分别初始化title、author、city、school和year等成员变量;

  2. 为city、school和year添加getter和setter方法。

  3. 重写reference()方法,返回字符串,格式为“作者.题名[D].保存地:保存单位,年份.”。

(4)构造一个Main类。

在main方法中,用Scanner对象输入数据,并创建一个Dissertation对象,并输出其参考文献的引文格式。

 java.util.Scanner;

 References{  
    String reference() 
}

class Paper{    
    private String title;  
    private String author; 

    public Paper(String title, String author) {  
        this.title = title;
        this.author = author;
    }

    public String getTitle() {  
        return title;
    }

    public void setTitle(String title) { 
        this.title = title;
    }

    public String getAuthor() {  
        return author;
    }

    public void setAuthor(String author) { 
        this.author = author;
    }
}

class Dissertation  Paper  References{  
    private String city;     
    private String school;   
    private int year;       

    public Dissertation(String title, String author, String city, String school, int year) { 
        
        this.city = city;
        this.school = school;
        this.year = year;
    }

    public String getCity() { 
        return city;
    }

    public void setCity(String city) { 
        this.city = city;
    }

    public int getYear() { 
        return year;
    }

    public void setYear(int year) { 
        this.year = year;
    }

    public String getSchool() {  
        return school;
    }

    public void setSchool(String school) { 
        this.school = school;
    }

    @Override
    public String reference() {  
        return  + "." +  + "[D]." + city + ":"
                + school + "," + year + ".";
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner();
        Dissertation journalPaper = new Dissertation(scanner.next(), scanner.next(), scanner.next(),
                scanner.next(), scanner.);

        System.out.println(journalPaper.reference());
    }
}

输入样例:

基于深度学习的车牌识别的研究与实现 张三 杭州 浙江传媒学院 2022

输出样例:

张三.基于深度学习的车牌识别的研究与实现[D].杭州:浙江传媒学院,2022.