标题:请教!!!!!!!!!!
只看楼主
zhangbin55661
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-4-6
结帖率:0
 问题点数:0 回复次数:0 
请教!!!!!!!!!!
//*假定每个形状又一个(X,Y)原点*/
Point类
public class Point
  { Private double myX;
    Private double myY;
    public Point(double x,double y)
        {myX=x;myY=y;}
    public Point()
      { my=0;myY=0;}
    public double getX()
      {return myX;}
    public double getY()
      {return myY}
    public void setPoint(double x,double y)
      {myX=x;myY=y;}

  }
/*RGB颜色表示方法*/
Public class Color
  { Private int blue;
    Private int green;
    Private int red;
  public Color(int r,int g,int b)
      {red=r;green=g;red=b;}
  public int getB()
    { return blue;}
  public int getG()
    {return  green;}
  public int getR()
    {return red;}
  public void setRGB(int r,int g,int b)
    {red=r;green=g;blue=b;}

  }

/*各种形状的抽象类*/

public abstract class Shape
  private Color color;
  private Point origin;

  protected Shape(Color col,Point org)
    { origin=new Point(org.getX(),org.getY());
      color=new Color(col.getR(),col.getG(),col.getB());
  }

  protected Shape(Point org)
      {  Origin=new Point(org.getX(),org.getY());
        Color=new Color(0,0,0);
  }

  protected Shape()
  {  Origin=new Point(0.0,0.0);/原点为(0,0)/
        Color=new Color(0,0,0);
    }

  public abstract double area();
  public abstract double perimeter();

  public Color getColor()
    {  return color;}
  public void setColor(Color col)
  { color.setRGB(col.getR(),col.getG(),col.getB());}
  pubilc Point getOrigin()
    { return origin;}
  public void setOrigin(Point org)
    {  origin.setPoint( org.getX(),org.getY(());
    }

  1. public int getB()
    { return blue;}这中方法对于调用他的类来说有什么用处;
  2.Shape类中三个构造方法是实现什么功能的(第三个应该是初始话吧);
  3.public Color getColor()
    {  return color;}
  返回的是不是Color类型的三个颜色值啊?
搜索更多相关主题的帖子: double public Private myY Point 
2008-07-27 15:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-225435-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.403839 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved