package day2;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JPanel;
public class TJPanel extends JPanel{
//乌龟的初始位置
int x = 300;
int y = 200;
//乌龟脚的初始位置
int k1 = 300,t1 = 200;//左上
int k2 = 300,t2 = 200;//右上
int k3 = 300,t3 = 200;//左下
int k4 = 300,t4 = 200;//右下
//Graphics g:画笔
@Override
public void paint(Graphics g) {
// TODO Auto-generated method stub
super.paint(g);
this.setBackground(Color.cyan);
/* //给画笔设置颜色
g.setColor(Color.RED);
//画矩形
g.drawRect(20, 150, 400, 200);
//画实心
g.fillRect(120, 200, 160, 80);
//画圆
g.drawOval(30, 250, 100, 80);
g.fillOval(130,300,100,100);
//画奥迪车标
g.drawOval(50,60,70,70);
g.drawOval(100,60,70,70);
g.drawOval(150,60,70,70);
g.drawOval(200,60,70,70);
//画线段
g.drawLine(80, 80, 300, 350);
*/
g.setColor(Color.GREEN);
g.fillOval(x, y, 70, 100);
//加眼睛
g.setColor(Color.BLACK);
g.fillOval(x + 10, y + 30, 10, 15);
g.fillOval(x + 50, y + 30, 10, 15);
//加舌头
g.setColor(Color.RED);
g.fillOval(x + 30, y, 8, 6);
//画脚 左上
g.setColor(Color.GREEN);
g.fillOval(k1 - 85, t1 + 75, 60, 70);
//画脚 右上
g.fillOval(k2 + 85 , t2 + 75, 60, 70);
//画脚 左下
g.fillOval(k3 - 85 , t3 + 235, 60, 70);
//画脚 右下
g.fillOval(k3 + 85 , t3 + 235, 60, 70);
//加乌龟壳
g.setColor(Color.ORANGE);
g.fillOval(x - 66, y + 69, 200, 250);
//壳加文字
g.setColor(Color.BLUE);
//设置字体的大小
Font font = new Font(Font.DIALOG,Font.BOLD,30);
g.setFont(font);
g.drawString("座 驾",x - 20,y + 180);
}
}
package day2;
import java.util.Scanner;
/**
* switch语句:
*
* 表达式的值:byte,short,int,char
*
* jdk1.5之后,加入了枚举类型
* jdk1.7之后,加入了String类型
*
* break:中断switch语句的执行
* default:所有的情况都不匹配的时候,就执行该处的语句块;
*
* switch语句的执行顺序(重点)
* @author Administrator
*
*/
public class OperatorDemo15 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入1-7整数:");
int day = sc.nextInt();
switch(day){
case 1:
System.out.println("星期一");
break;
case 2:
System.out.println("星期二");
break;
case 3:
System.out.println("星期三");
break;
case 4:
System.out.println("星期四");
//break;
case 5:
System.out.println("星期五");
break;
case 6:
System.out.println("星期六");
break;
case 7:
System.out.println("星期日");
break;
default:
System.out.println("有误");
}
}
}
package day2;
/**
* 程序考虑数据
* 安全性数据
* 边界数据
* 错误数据
*
*/
import java.util.Scanner;
public class OperatorDemo13 {
public static void main(String[]args){
Scanner input = new Scanner(System.in);
System.out.println("请输入一个数:");
int a = input.nextInt();
if (a >= 90 && a <= 100){
System.out.println("最强王者");
}else if(a >= 80 && a < 90){
System.out.println("星耀");
}else if(a >= 70 && a < 80){
System.out.println("钻石");
}else if(a >= 60 && a < 70){
System.out.println("黄金");
}else{
System.out.println("黑铁");
}
}
}