java中資料表中簡單的類一對多關係

2021-08-11 15:41:23 字數 1465 閱讀 5543

查詢表中的所有雇員資訊,以及查詢每個員工的部門資訊和領導資訊

注意看返回值的型別

/** to change this license header, choose license headers in project properties.

* to change this template file, choose tools | templates

* and open the template in the editor.

*/package testdemo;

/*** * @author jone

*/

class emp;

public emp(int empno, string ename, string job, double sal, double comm)

public void setmgr(emp mgr)

public emp getmgr()

public void setdept(dept dept)

public dept getdept()

public void setempno(int empno)

public void setename(string ename)

public void setjob(string job)

public void setsal (double sal)

public void setcomm (double comm)

public int getempno()

public string getename()

public string getjob()

public double getsal()

public double getcomm()

public string getempinfo()

}class dept

public dept(int deptno, string dname, string loc)

public void setemps(emp emps)

public emp getemps()

public void setdeptno(int deptno)

public void setdnama(string dname)

public void setloc(string loc)

public int getdeptno()

public string getdname()

public string getloc()

public string gerdeptinfo()

}public class testdemo );

//第二步進行資料的取得

//輸出一部門的全部雇員

system.out.println(dept.gerdeptinfo());

for(int i=0; i

資料表與簡單java類(多對多)

定義乙個學生選課的操作表 三張表 學生表 編號,姓名,年齡 課程表 課程編號,課程名稱,學分 學生 課程關聯表 學生編號,課程編號,成績。要求可以輸出如下資訊 1 可以找到一門課程參加此課程的所有資訊以及成績 2 根據乙個學生,找到所參加的所有課程和每門課程的成績 第一步 定義出基本類,暫不考慮所有...

資料表與簡單Java類(多對多)

定義乙個學生選課的操作表 三張資料表 要求 可以實現如下的資訊輸出 定義出基本類,暫時不考慮所有的關係class student public student int stuid,string name,int age public string getinfo class course publi...

資料表與簡單java類對映 角色許可權

先上模板 class dept public string getinfo class emp public string getinfo class role public string getinfo class action public string getinfo 再上 class dep...