12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package com.sinosoft.cm.test;
- import java.util.List;
- import com.sinosoft.cm.common.ArrayList;
- import com.sinosoft.cm.common.JOSNString;
- public class ClassRoom extends JOSNString{
- public String no=null;;
- public List classMate=null;
- //方案1继承JOSNString的toString方法,简单,效率相对较低不易出错
- //方案2重写重写toString方法,效率高,复杂易出错
-
- @Override
- public String toString() {
- return "{\"no\":\""+no+"\",\"classMate\":"+classMate+"}";
- }
- public ClassRoom(){
- super();
- classMate=new ArrayList();
- }
- public ClassRoom(String num){
- classMate=new ArrayList();
- this.no=num;
- }
- public String getNo() {
- return no;
- }
- public void setNo(String no) {
- this.no = no;
- }
- public List getClassMate() {
- return classMate;
- }
- public void setClassMate(ArrayList classMate) {
- this.classMate = classMate;
- }
- public void addPeople(People peo){
- classMate.add(peo);
- }
- }
|