import java.util.HashMap;
import java.io.*;
import java.util.*;
public class Fegan implements Comparable{
HashMap<String, Integer> cart = new HashMap<String, Integer>();
List list = new ArrayList<FoodItems>();
int x =0;
public void addToCart(FoodItems f)
{
cart.put(f.name, f.valueOfFood);
}
public String display(FoodItems f)
{
return(f.name + " costs " + f.valueOfFood);
}
public void addToList(FoodItems f)
{
//FoodItems temp = (FoodItems) f;
list.add(f);
}
public int compareTo(Object o)
{
//FoodItems temp = (FoodItems) o;
if(this.x == ((FoodItems)o).valueOfFood)
return 0;
else if (this.x <((FoodItems)o).valueOfFood)
return 1; …
Run Code Online (Sandbox Code Playgroud) 我有一个测试文件,根据它,我需要构建我的程序,测试文件在下面.但是,我对s1.showDetails(System.out)感到困惑; 我从来没有遇到参数System.out任何人都可以帮助.怎么办呢??? 当我尝试编写showDetails()时,编译器会写错误.我的学生代码在此之下谢谢你提前!
import java.util.*;
public class Q2 {
public static void main(String [] args)
{
// Start on section A
System.out.println("Question 2");
System.out.println("Start on part A");
Student s1 = new Student("John", "Smith", 42);
s1.showDetails(System.out);
Course cs = new Course("Computer science");
}
}
public class Student {
private String name;
private String familyName;
private int moduleMark;
private int total;
protected Student(String name, String familyName, int moduleMark)
{
this.name = name;
this.familyName = familyName;
this.moduleMark = moduleMark;
}
public String getName() …
Run Code Online (Sandbox Code Playgroud) import java.util.*;
public class Test {
public static void main(String[] args) {
List db = new ArrayList();
ShopDatabase sb = new ShopDatabase(db);
sb.addEntry(new ProductEntry("film", 30, 400));
sb.addEntry(new CashierEntry("Kate", "Smith", 23, 600));
sb.addEntry(new ManagerEntry("Jack", "Simpson", 1, 700));
sb.addEntry(new ProductEntry("soap", 18, 3));
sb.addEntry(new ManagerEntry("Helen", "Jones", 60, 650));
sb.addEntry(new CashierEntry("Jane", "Tomson", 15, 900));
sb.addEntry(new ProductEntry("shampoo", 25, 5));
sb.addEntry(new CashierEntry("Bill", "Black", 59, 300));
Collections.sort(db);
Iterator itr = db.iterator();
while (itr.hasNext()) {
Entry element = (Entry) itr.next();
System.out.println(element + "\n");
}
}
}
public abstract …
Run Code Online (Sandbox Code Playgroud) java ×3