日期:2014-05-20  浏览次数:20671 次

关于java.lang里的一个问题 需要回看类图 Orz
做一道题目的时候有个几个方法不知道编写?请高手看过题目后再看看我写的指导下Orz     问题有点长请见谅啊

题目:   (The   person   and   student   class)creat   the   class   as   shown   in   figure   ***(即待会我打的类图)

Implement   the   compareTo   method   in   the   Person   class   to   compare   persons   in   the   compareTo   methed   to   compare   students   in   alphabetical   order   of   their   major   of   their   major,last   name,first   name,and   middle   initial.
write   a   test   program   with   the   following   three   metheds
/**Sort   an   arry   of   comparable   objects   */
        public   static   void   sort(Object[]   list)
/**   Return   the   max   object   in   an   array   of   comparable   objects*/
        public   static   Object   max(Object[]   list)
main   method:   Test   the   sort   and   max   methed   using   an   array   of   four   students,   an   array   of   four   Strings,   an   array   of   one   houndred   random   rationals,   and   array   of   one   houndred   random   integers.


类图:

Person         ....△java.lang.Comparable
_____________
-name:Name
_____________
+Person   (name:Name)
+getName():Name
+setName(name:Name):void
+toString():String
+equals(object:Object):boolean
+comparTo(object:Object):int


Name         -----◆Person
____________________
-firstName:String
-mi:char
-lastName:String
____________________
+Name(firstName:String,mi:char,lastName:String)
+getFirstName():String
+setFirstName(firstName:String):void
+getMi():char
+setMi(mi:char):void
+getLastName():String
+setLastName(lastName:String):void
+getFullName():String


Student         -------(實綫)△Person
_______________
-major:String
_______________
+student(name:Name,major:String)
+getMajor():String
+setMajor(major:String):void
+toString():String
+compareTo(object:Objext):int

以下是我编写的

public   class   Name   {

private   String   firstName;
private   char   mi;
private   String   lastName;

        public   Name()   {
       
        }
       
        public   String   getFirstName(){
       
        return   firstName;
        }
       
        public   void   setFirstName(String   firstName){
       
        this.firstName   =   firstName;
        }
       
        public   char   getMi(){
       
        return   mi;
        }
       
        public   void   setMi(char   mi){