【发布时间】:2021-01-09 21:12:15
【问题描述】:
我试图做的基本上是迭代我的流派并将我的 hashMap 用作查找表,然后在创建对象时选择流派。我不知道接下来我需要做什么,因为当我已经有了一个新的构造函数时,它总是给我创建一个新的构造函数的错误。
import java.util.HashMap;
import java.util.Scanner;
public class disc {
private String title;
private String releaseDate;
HashMap<Integer, String> genre = new HashMap<Integer, String>();
Scanner mainInput = new Scanner(System.in);
public disc(String releaseDate, String title, HashMap<Integer, String> genre) {
this.title = title;
this.releaseDate = releaseDate;
this.genre = genre;
this.genre.put(1, "Horror");
this.genre.put(2, "Action");
this.genre.put(3, "Hip-Hop");
this.genre.put(4, "Pop");
this.genre.put(5, "Jazz");
this.genre.put(6, "Thriller");
}
子类:
import java.util.HashMap;
public class game extends disc{
private int PEGIRating;
private String Platform;
public game(int PEGIRating, String Platform, String title, String releaseDate, HashMap<Integer, String> genre){
super(releaseDate, title, genre);
this.PEGIRating = PEGIRating;
this.Platform = Platform;
game g = new game(18,"PS5","Evil Within","Feb 2018",1);
}
}
【问题讨论】:
标签: java hashmap subclass superclass