Java3-class Student

Source: Internet
Author: User

1  PackageOne ;2 ImportJava.util.*;3 Importjava.text.*;4 classperson{5      PublicString name;6      PublicDate birthday;7      PublicString sex, province,city;8     Private Static intCount=0;9      PublicPerson (String name,date birthday,Ten String sex,string province,string City) { One          This. name=name; A          This. birthday=birthday; -          This. sex=sex; -          This. province=Province; the          This. city=City ; -     } -      PublicPerson (String name,date birthday) { -          This(Name,birthday, "", "", ""); +     } -      PublicPerson () { +          This("",NULL); A     } at      PublicPerson (person p) { -          This. Set (p.name,p.birthday,p.sex,p.province,p.city); -     } -      -      Public voidFinalize () { -System.out.println ("Release object (" + This. toString () + ")"); inperson.count--; -     } to      PublicString toString () { +         returnName+ "," + (birthday==NULL? "": birthday.tostring ()) + "," + -(sex==NULL? "": Sex) + "," + (province==NULL? "":p rovince) + the(city==NULL?"": City); *     } $      Public voidSet (String name,date birthday,string sex,string Province,Panax Notoginseng String City) { -          This. name=name==NULL?"": Name; the          This. sex=sex==NULL?"": Sex; +          This. province=province==NULL?"":p rovince; A          This. city=city==NULL?"": City; theCalendar calendar=NewGregorianCalendar (0000,00,00,0,0,0); +Date date=calendar.gettime (); -          This. birthday=birthday==NULL?Date:birthday; $     } $      Public Static voidHowmany () { -System.out.println (person.count+ "Person Object"); -     } the } - Wuyi  Public classStudentextendsPerson { the      PublicString Department; -      PublicString number; Wu      PublicString speciality; -      Public Booleanmember; About     Private Static intCount=0; $      PublicStudent (String name,date birthday,string sex,string Province, - String city,string number,string department,string speciality, -             Booleanmember) { -         Super. Set (name, birthday, sex, province, city); A          This. Set (Number,department,speciality,member); +count++; the     } -      Public voidSet (String number,string department,string specilality, $             Booleanmember) { the          This. number=number==NULL?"": number; the          This. department=department==NULL?"":d epartment; the          This. speciality=speciality==NULL?"": Speciality; the          This. member=member; -     } in      Public voidFinalize () { the         Super. Finalize (); thestudent.count--; About     } the      PublicStudent (person p,string number,string department,string speciality, the             Booleanmember) { the          This(P.name,p.birthday,p.sex,p.province,p.city,number,department, +Speciality,member);//There is no point behind this -     } the      PublicStudent (Student s) {Bayi          This(S.name,s.birthday,s.sex,s.province,s.city,s.number, the s.department,s.speciality,s.member); the     } -      Public Static voidHowmany () { - Person.howmany (); theSystem.out.println (student.count+ "Student objects"); the     } the      PublicString toString () { the         return Super. toString () + "," +department+ "," +speciality+ "," +number+ -"," + (member? ") Member ":"); the     } the      Public Static voidMain (string[] args) { the         //TODO auto-generated Method Stub94  the     } the  the}

Java3-class Student

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.