java教师_Java学生类教师类

java教师_Java学生类教师类展开全部publicclassStudent{Integerid;//等其他String,int型Setteachers;Setcourses;publicStudent(Integerid){this.id=id;}publicStudent(Integerid,Setteachers,Setcourses){this.id=id;this.teachers=…

大家好,又见面了,我是你们的朋友全栈君。

展开全部

public class Student{

Integer id;//等其他String,int型

Set teachers;

Set courses;

public Student(Integer id){

this.id = id;

}

public Student(Integer id, Set teachers, Set courses){

this.id = id;

this.teachers = teachers;

this.courses = courses;

}

public Integer getId(){

return id;

}

public void setId(Integer id){

this.id = id;

}

//其他类型略

public Set getTeachers(){

return teachers;

}

public setTeachers( Set teachers){

this.teachers = teachers;

}

//课程类似

}

教师类,636f707962616964757a686964616f31333335333761课程类类似。

以下是实现:public static void main(String [] args){

Student s1 = new Student(1);

Teacher t1 = new Teacher(1);

Teacher t2 = new Teacher(2);

Course c1 = new Course(1);

Course c2 = new Course(2);

Set studentSet = new HashSet();

studentSet.add(s1);

Set teacherSet = new HashSet();

teacherSet.add(t1);

teacherSet.add(t2);

Set courseSet = new HashSet();

courseSet.add(c1);

courseSet.add(c2);

s1.setTeachers(teacherSet );

t1.setStudents(studentSet);

t2.setStudents(studentSet);

s1.setCourses(courseSet);

c1.setStudent(studentSet);

c2.setStudent(studentSet);

//老师课程同理

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/156458.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Conscript_const let var

    Conscript_const let var1.let命令基本语法ES6新增了let命令,用来声明变量。它的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效。{leta=1varb=2console

    2022年7月29日
    3
  • Linux服务器集群_rtmp服务器集群

    Linux服务器集群_rtmp服务器集群Reference: http://www.linuxvirtualserver.org/zh/lvs1.htmlLVS项目介绍章文嵩 (wensong@linux-vs.or

    2022年8月5日
    4
  • 系统日志查看journalctl命令详解

    系统日志查看journalctl命令详解简介从2012年开始,大部分linux发行版本开始从传统的systemv初始化系统移植到一个叫做systemd的全新系统。systemd用来启动系统并管理进程。systemd包含了一个叫做journalctl的辅助组件,其主要作用是管理系统的事件日志记录。journalctl可以查看所有的系统日志文件,由于日志信息量很大,journalctl还提供了各种参数帮助用户更快速的定位到日志信息。默认情况下,用户都可以访问自己的日志。对于系统主日志和其他用户的日志,仅限于有权限的用户访问,比如root用户,

    2022年5月10日
    37
  • SQL可视化工具_可视化工具tableau

    SQL可视化工具_可视化工具tableauSQLite数据库的特性特点:1.轻量级2.独立性,没有依赖,无需安装3.隔离性全部在一个文件夹系统4.跨平台支持众多操作系统5.多语言接口支持众多编程语言6.安全性事物,通过独占性和共享

    2022年8月6日
    3
  • javaweb-爬虫-2-63

    javaweb-爬虫-2-63

    2021年5月18日
    137
  • The method assertEquals(double, double) from the type Assert is deprecated

    The method assertEquals(double, double) from the type Assert is deprecated从网上下载的视频,看着视频做。居然和人家的不一样。assertEquals(doubleexpected,doubleactul)被废弃了,换成assertEquals(doubleexpected,doubleactul,doubledelta)也就是在原来的方法上加一个误差值(double类型)官方解释为:@Deprecatedstaticpublicvoi

    2022年7月12日
    17

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号