问题描述
大家好,我正在尝试使用 groovy 在课堂上实现接口 trait。但它不起作用。有人可以建议吗?
interface Salary
{
void displaySalary();
}
trait Employee implements Salary
{
public void displaySalary()
{
println(s*12);
}
public displayID()
{
println(i);
}
}
class Company implements Employee
{
public Company (int s,int i)
{
this.s=s;
}
}
class Solution {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int s = sc.nextInt();
int i = sc.nextInt();
def c = new Company(s,i);
c.displaySalary();
c.displayID();
}
}```
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)