java incomp_java错误incompatible types

importjava.awt.*;importjavax.swing.JApplet;publicclassCanzhuoextendsJApplet{publicDinnerc1,c2,c3,c4,c5,c6,c7;intnum=-1;publicvoidinit(){Dinnerc1=newDinner("1",'男');Dinne...

import java.awt.*;

import javax.swing.JApplet;

public class Canzhuo extends JApplet

{ public Dinner c1,c2,c3,c4,c5,c6,c7;

int num = -1;

public void init() {

Dinner c1 = new Dinner("1", '男');

Dinner c2 = new Dinner("2", '女');

Dinner c3 = new Dinner("3", '女');

Dinner c4 = new Dinner("4", '男');

Dinner c5 = new Dinner("5", '女');

Dinner c6 = new Dinner("6", '男');

Dinner c7 = new Dinner("7", '女');

// public static

setBackground(Color.black); //设置背景色

}

public void paint(Graphics page) {

super.paint(page);

final int MIDX = 400;

final int MIDY = 400;

int midx,midy;

page.setColor(Color.blue);

page.fillOval(MIDX - 100, MIDY - 100, 200, 200);

c1.draw(page);

c2.draw(page);

c3.draw(page);

c4.draw(page);

c5.draw(page);

c6.draw(page);

c7.draw(page);

}

class Dinner {

String name;

char sex;

int sate;

Dinner(String s, char c) { //构造方法

name = s;

sex = c;

num++;

sate = num;

}

public void draw(Graphics page) { //画每个人的座位...

int midx, midy;

double alfa = 360 * sate / num;

if (sex == '男') {

page.setColor(Color.blue);

}

else {

page.setColor(Color.red);

}

midx = MIDX + (int) (150 * Math.cos(alfa));

midy = MIDY + (int) (150 * Math.sin(alfa));

page.fillRect(midx - 20, midy - 20, 40, 40);

page.setFont(new Font("隶书", Font.BOLD, 30)); //设置字型为隶书粗体

page.setColor(Color.yellow);

page.drawString(name, midx - 15, midy - 15);

}

}

}

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值