我有 3 个不同的类,其方法相同,返回类型为字符串,如何通过再创建一个类来显示所有这些方法

发布于 2025-01-14 09:43:25 字数 1161 浏览 2 评论 0原文

我有 3 个不同的类,其方法相同,返回类型为字符串,如何通过创建另一个类来显示所有这些方法,我尝试通过使用对象创建其他类来调用

public class SuperDepartment {
    public String departmentName() {
        return "Super Department" ;
    }
    public String getTodaysWork() {
        return "No Work as of now" ;
    }
    public String getWorkdeadline() {
        return "Nill" ;
    }
    public String isTodayAHoliday() {
        return "Today is not a holiday" ;
    }

public class AdminDepartment extends SuperDepartment {
public String  departmentName() {
        
        return "Admin department";
        
        
    }
    public String getTodaysWork() {
        return "Complete your document submission";
        
    }
    public String getWorkDeadline() {
        return "Complete by EOD";
    }
    
}

public class HrDepartment extends SuperDepartment {
public String departmentName() {
        return "Hr Department";
    }
    public String getTodaysWork() {
        return "Fill todays worksheet and mark your attendence";
    }
    public String getWorkDeadline() {
        return "Complete by EOD";
    }
    public String doActivity() {
        return "team Lunch";
    }

I have 3 different classes with same method that having return type string ,how can i display all these method by creating one more class, i have tried to call by creating other class with object

public class SuperDepartment {
    public String departmentName() {
        return "Super Department" ;
    }
    public String getTodaysWork() {
        return "No Work as of now" ;
    }
    public String getWorkdeadline() {
        return "Nill" ;
    }
    public String isTodayAHoliday() {
        return "Today is not a holiday" ;
    }

public class AdminDepartment extends SuperDepartment {
public String  departmentName() {
        
        return "Admin department";
        
        
    }
    public String getTodaysWork() {
        return "Complete your document submission";
        
    }
    public String getWorkDeadline() {
        return "Complete by EOD";
    }
    
}

public class HrDepartment extends SuperDepartment {
public String departmentName() {
        return "Hr Department";
    }
    public String getTodaysWork() {
        return "Fill todays worksheet and mark your attendence";
    }
    public String getWorkDeadline() {
        return "Complete by EOD";
    }
    public String doActivity() {
        return "team Lunch";
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文