学生党java作业,在线求解答。
1定义满足下列条件的Pen类,并创建其对象进行测试。Pen类拥有的属性:笔尖的粗细、墨水量、墨水颜色、有无笔帽、长度及半径Pen类拥有的方法:画图、写字、更换墨水2定义一...
1 定义满足下列条件的Pen类,并创建其对象进行测试。 Pen类拥有的属性:笔尖的粗细、墨水量、墨水颜色、有无笔帽、长度及半径 Pen类拥有的方法:画图、写字、更换墨水 2定义一个满足下列要求的Point类,并创建其对象进行测 Point类拥有x坐标、 y坐标,并提供获取坐标及改变坐标的方法。
展开
3个回答
展开全部
class Pen{
private int thickness;
private int capacity;
private int colore;
private boolean cap;
private int len;
private int radius;
public Pen(int thickness,int capacity,int colore,boolean cap,int len,int radius){
this.thickness=thickness;
this.capacity=capacity;
this.colore=colore;
this.cap=cap;
this.len=len;
this.radius=radius;
}
public void paint(){
}
public void write(){
}
public void changeInk(int capacity,int colore){
this.capacity=capacity;
this.colore=colore;
}
}
class Point{
private int x;
private int y;
public Point(int x,int y){
this.x=x;
this.y=y;
}
public int getX(){
return x;
}
public int getY(){
return y;
}
void change(int x,int y){
this.x=x;
this.y=y;
}
}
public class Test{
public static void main(string[] x){
Pen p=new Pen(2,100,3,true,4,30);
p.changeInk(40,4);
Point p2=new Point(200,400);
p2.change(230,240);
}
}
private int thickness;
private int capacity;
private int colore;
private boolean cap;
private int len;
private int radius;
public Pen(int thickness,int capacity,int colore,boolean cap,int len,int radius){
this.thickness=thickness;
this.capacity=capacity;
this.colore=colore;
this.cap=cap;
this.len=len;
this.radius=radius;
}
public void paint(){
}
public void write(){
}
public void changeInk(int capacity,int colore){
this.capacity=capacity;
this.colore=colore;
}
}
class Point{
private int x;
private int y;
public Point(int x,int y){
this.x=x;
this.y=y;
}
public int getX(){
return x;
}
public int getY(){
return y;
}
void change(int x,int y){
this.x=x;
this.y=y;
}
}
public class Test{
public static void main(string[] x){
Pen p=new Pen(2,100,3,true,4,30);
p.changeInk(40,4);
Point p2=new Point(200,400);
p2.change(230,240);
}
}
展开全部
1、class Pen{
public float weight=0.5f;//粗细
public int quantity = 100;//墨水量
public String color = "black";//墨水颜色
public boolean haveCap = false;//有无笔帽
public float len = 15f;//长度
public float radius = 2f;//半径
public void draw(){
//画图
}
public void write(String s){
//写字
}
public void change(int quantity){
//更换墨水
this.quantity = quantity;
}
}
2、class Point{
private double x;
private double y;
public void setX(double x){
this.x = x;
}
public double getX(){
return this.x;
}
public void setY(double y){
this.y = x;
}
public double getY(){
return this.y;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
分数有点少 不值得动手
追问
帮帮忙吧,大神,谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询