You are on page 1of 2

Cu 1: Thit k v ci t mt lp tru tng c tn GeometricObject dng biu din cc i tng hnh hc vi cc yu cu sau: - Mt bin ring (private) kiu chui

i tn color lu gi mu sc ca i tng hnh hc, mu mc nh l white. - Mt bin ring (private) kiu logic tn filled ch tnh trng i tng hnh hc c t mu hay cha. - Mt bin ring (private) kiu ngy gi lu gi ngy gi to lp. - Mt phng thc khi to mc nh khng tham s to mt i tng hnh hc vi ngy gi hin ti l ngy gi to lp. - Cc phng thc ly v t gi tr cho cc thuc tnh ca i tng hnh hc, s dng cc khai bo: public String getColor(), public void setColor(String color), public boolean isFilled(), public void setFilled(boolean filled), public java.util.Date getDateCreated() - Mt phng thc tr li mt xu miu t i tng (ngy gi to lp, mu sc, c t hay khng), s dng khai bo: public String toString() - Mt phng thc tru tng nhm tnh din tch ca i tng hnh hc c tn getArea(). - Mt phng thc tru tng nhm tnh chu vi ca i tng hnh hc c tn getPerimeter(). Cu 2: Thit k v ci t mt lp c tn Rectangle biu din cc i tng hnh ch nht m rng t lp GeometricObject theo cc yu cu sau: - Cc bin ring kiu s thc c tn width v height lu gi chiu rng v chiu cao ca hnh ch nht. - Mt phng thc khi to mc nh khng tham s. - Mt phng thc khi to vi tham s l chiu rng v chiu cao - Cc phng thc ly v t gi tr cho cc thuc tnh ca i tng hnh ch nht, s dng khai bo: public double getWidth(),public void setWidth(double width), public double getHeight(),public void setHeight(double height). - Ci t cc phng thc (k tha t lp GeometricObject) tnh din tch v chu vi ca hnh ch nht. Cu 3: Thit k v ci t mt lp c tn Circle biu din cc i tng hnh trn m rng t lp GeometricObject theo cc yu cu sau: - Mt bin ring kiu s thc c tn radius lu gi bn knh ca hnh trn. - Mt phng thc khi to mc nh khng tham s. - Mt phng thc khi to vi tham s l bn knh ca hnh trn. - Cc phng thc ly v t gi tr cho bn knh hnh trn, s dng khai bo: public double getRadius(), public void setRadius(double radius) - Mt phng thc tr li ng knh ca hnh trn, c khai bo dng: public double getPerimeter() - Ci t cc phng thc tnh din tch v chu vi hnh trn. Cu 4: Vit mt lp c tn TestGeometricObject theo cc yu cu sau: - Mt phng thc cho bit din tch ca hai i tng tham s truyn vo c bng nhau hay khng, s dng khai bo:

public static boolean equalArea(GeometricObject object1, GeometricObject object2) - Mt phng thc dng hin th din tch v chu vi ca i tng hnh hc, s dng khai bo: public static void displayGeometricObject(GeometricObject object). Mt phng thc main trong to mt i tng hnh trn c bn knh l 5 l mt i tng hnh ch nht c chiu rng l 5, chiu cao l 3; cho bit hai i tng c din tch bng nhau hay khng; s dng phng thc displayGeometricObject va to trn hin th din tch v chu vi ca cc i tng .