java3- class student

 1 package one;
 2 import java.util.*;
 3 import java.text.*;
 4 class person{
 5     public String name;
 6     public Date birthday;
 7     public String sex ,province,city;
 8     private static int count=0;
 9     public person (String name,Date birthday,
10             String sex,String province,String city){
11         this.name=name;
12         this.birthday=birthday;
13         this.sex=sex;
14         this.province=province;
15         this.city=city;
16     }
17     public person(String name,Date birthday){
18         this(name,birthday,"","","");
19     }
20     public person(){
21         this("",null);
22     }
23     public person (person p){
24         this.set(p.name,p.birthday,p.sex,p.province,p.city);
25     }
26
27     public void finalize(){
28         System.out.println("释放对象("+this.toString()+")");
29         person.count--;
30     }
31     public String toString(){
32         return name+","+(birthday==null?"":birthday.toString())+","+
33             (sex==null?"":sex)+","+(province==null?"":province)+
34             (city==null?"":city);
35     }
36     public void set(String name,Date birthday,String sex,String province,
37             String city){
38         this.name=name==null?"":name;
39         this.sex=sex==null?"":sex;
40         this.province=province==null?"":province;
41         this.city=city==null?"":city;
42         Calendar calendar=new GregorianCalendar(0000,00,00,0,0,0);
43         Date date=calendar.getTime();
44         this.birthday=birthday==null?date:birthday;
45     }
46     public static void howMany(){
47         System.out.println(person.count+"个 person 对象");
48     }
49 }
50
51 public class Student extends person {
52     public String department;
53     public String number;
54     public String speciality;
55     public boolean member;
56     private static int count=0;
57     public Student(String name,Date birthday,String sex,String province,
58             String city,String number,String department,String speciality,
59             boolean member){
60         super.set(name, birthday, sex, province, city);
61         this.set(number,department,speciality,member);
62         count++;
63     }
64     public void set(String number,String department,String specilality,
65             boolean member){
66         this.number=number==null?"":number;
67         this.department=department==null?"":department;
68         this.speciality=speciality==null?"":speciality;
69         this.member=member;
70     }
71     public void finalize(){
72         super.finalize();
73         Student.count--;
74     }
75     public Student(person p,String number,String department,String speciality,
76             boolean member){
77         this(p.name,p.birthday,p.sex,p.province,p.city,number,department,
78                 speciality,member);//this 后面没有点
79     }
80     public Student(Student s){
81         this(s.name,s.birthday,s.sex,s.province,s.city,s.number,
82                 s.department,s.speciality,s.member);
83     }
84     public static void howMany(){
85         person.howMany();
86         System.out.println(Student.count+"个 student对象");
87     }
88     public String toString(){
89         return super.toString()+","+department+","+speciality+","+number+
90                 ","+(member?"团员":"");
91     }
92     public static void main(String[] args) {
93         // TODO Auto-generated method stub
94
95     }
96
97 }
时间: 2024-10-26 21:32:07

java3- class student的相关文章

551. 学生出席记录 Student Attendance Record I

You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more than o

设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1-2的表(一)~表(四)所示。用SQL语句创建四个表并完成相关题目。

表(一)Student (学生表) -- Create table create table STUDENT ( sno VARCHAR2(3) not null, sname VARCHAR2(8) not null, ssex VARCHAR2(2) not null, sbirthday DATE, class VARCHAR2(5) ) tablespace USERS pctfree 10 initrans 1 maxtrans 255; -- Add comments to the

[LeetCode] Student Attendance Record I

You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more than o

github student pack中的digital ocean可以使用银联卡支付

申请了 github student pack却因为一直没有visita信用卡,而无法使用digital ocean的 $50,一直到今天,用中国银行借记卡成功支付. 方法是: (1)注册paypal账号,不需要绑定银行卡或信用卡. (2)打开digital ocean的welcome页面,那里会提示需要打入$5,支付方式可选“信用卡/借记卡”或者 “paypal”,选择paypal (3)进入支付页面,登陆paypal账户,输入银联卡(我的是中国银行)的卡号,然后填入后边的一些相关信息.点击“

Spring RPC 入门学习(3)-插入Student对象

Spring RPC 向后台传递对象 1. 新建RPC接口:StudentInterface.java package com.cvicse.ump.rpc.interfaceDefine; import com.cvicse.ump.student.Student; public interface StudentInterface { public Student getStudentById(String id); public Boolean insertStudent(Student

Spring RPC 入门学习(3)-获取Student对象

Spring RPC传递对象. 1. 新建RPC接口:StudentInterface.java package com.cvicse.ump.rpc.interfaceDefine; import com.cvicse.ump.student.Student; public interface StudentInterface { public Student getStudentById(String id); } 2.新建RPC接口的实现类,StudentManager.java pack

1047. Student List for Course (25)

题目例如以下: Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses. Input Specification: Each input file contains one te

Java基础知识强化之集合框架笔记60:Map集合之TreeMap(TreeMap<Student,String>)的案例

1. TreeMap(TreeMap<Student,String>)的案例 2. 案例代码: (1)Student.java: 1 package cn.itcast_04; 2 3 public class Student { 4 private String name; 5 private int age; 6 7 public Student() { 8 super(); 9 } 10 11 public Student(String name, int age) { 12 super

Java基础知识强化之集合框架笔记57:Map集合之HashMap集合(HashMap&lt;Student,String&gt;)的案例

1. HashMap集合(HashMap<Student,String>)的案例 HashMap<Student,String>键:Student      要求:如果两个对象的成员变量值都相同,则为同一个对象.值:String HashMap是最常用的Map集合,它的键值对在存储时要根据键的哈希码来确定值放在哪里. HashMap 中作为键的对象必须重写Object的hashCode()方法和equals()方法 2. 代码示例: (1)Student.java,如下: 1 pa