New-Microsoft-Word-Document-2.docx - Person.java package...

This preview shows page 1 - 3 out of 6 pages.

Person.javapackageQuestion4;public classPerson{protectedStringname;protectedStringaddress;publicPerson(Stringname,Stringaddress) {this.name=name;this.address=address;}publicStringgetName() {returnname;}publicvoidsetName(Stringname) {this.name=name;}publicStringgetAddress() {returnaddress;}publicvoidsetAddress(Stringaddress) {this.address=address;}@OverridepublicStringtoString() {return"Person [address="+address+", name="+name+"]";}}Student.javapackageQuestion4;public classStudentextendsPerson{privateintnumCourse=0;
String[] courses;int[] grades;publicStudent(Stringname,Stringaddress) {super(name,address);numCourse=0;courses=newString[30];grades=newint[30];}@OverridepublicStringtoString() {return"Student ["+super.toString()+"]";}publicvoidaddCourseGrade(Stringcourse,intgrade) {courses[numCourse]=course;grades[numCourse]=grade;++numCourse;}publicvoidprintGrades() {System.out.print(this);for(inti=0; i<numCourse;++i) {System.out.print(" "+courses[i]+":"+grades[i]);}System.out.println();}publicdoublegetAverageGrade() {intsum=0;for(inti=0; i<

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 6 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Summer
Professor
NoProfessor
Tags
Return statement, Void type, Override, public class Person

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture