第二天学习情况总结

package cn.ysq.day02;

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;
public void paint(Graphics g){
super.paint(g);
this.setBackground(Color.cyan);
//加龟头
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, 8);
//加龟壳
g.setColor(Color.YELLOW);
g.fillOval(x-80, y+80, 250,300);
//龟脚
g.setColor(Color.BLUE);
g.fillOval(x-80, y+60, 50, 100);
g.fillOval(x-110, y+230, 50, 100);
g.fillOval(x+120, y+60, 50, 100);
g.fillOval(x+140, y+230, 50, 100);
//尾巴
g.setColor(Color.GREEN);
g.fillOval(x, y+330, 70, 200);
//壳加文字
g.setColor(Color.RED);
g.drawString(“七彩琉璃龟”, x+40, y+200);
//设置字体大小
Font font = new Font(Font. DIALOG ,Font.BOLD,30);
g.setColor(Color.RED);
g.drawString(“七彩琉璃龟”, x-40, y+180);

	/*g.drawRect(20, 150, 400, 600);//矩形
	g.setColor(Color.RED);//设置颜色
	g.fillRect(120, 200,160,80 );//实心
	g.drawOval(30,250 ,100 ,80 );//圆
	g.fillOval(130, 300, 100, 100);//椭圆
	g.drawLine(80,80,300,350);//线段
	
	g.drawOval(30,250 ,80 ,80 );
	g.drawOval(90,250 ,80 ,80 );
	g.drawOval(150,250 ,80 ,80 );
	g.drawOval(210,250 ,80 ,80 );
	*/
	
	
	
}

}
在这里插入图片描述
package cn.ysq.day02;

import javax.swing.JFrame;
/**

  • JFrame 窗体 相框
  • JPanel画布 相片
  • 手动导包 import
  • 自动导包ctrl+shiift+0
  • 点击红色叉号
  • @author Administrator

*/
public class Turtlepro {
public static void main(String[] args){
JFrame frame = new JFrame();//创建一个窗体对象
frame.setTitle(“忍者神龟”);//给窗体添加标题
frame.setSize(1400,800);//大小
frame.setLocationRelativeTo(null);//居中
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TJpanel tj = new TJpanel();//画布
frame.add(tj);
frame.setVisible(true);//显示窗体

}

}

查询该年该月有多少天
package cn.ysq.day02;
import java.util.Scanner;
public class OperatorDemo9 {
public static void main(String[] args){
Scanner sc = new Scanner (System.in);
System.out.println(“请输入你的年份:”);
int x =sc.nextInt();
System.out.println(“请输入你的月份:”);
int y =sc.nextInt();
if( x % 4 ==0 && x % 100!=0 || x % 400 0&y2){
System.out.println(“29”);
}
else{
switch(y){
case 1:
System.out.println(“31”);
break;
case 2:
System.out.println(“28”);
break;
case 3:
System.out.println(“31”);
break;
case 4:
System.out.println(“30”);
break;
case 5:
System.out.println(“31”);
break;
case 6:
System.out.println(“30”);
break;
case 7:
System.out.println(“31”);
break;
case 8:
System.out.println(“31”);
break;
case 9:
System.out.println(“30”);
break;
case 10:
System.out.println(“31”);
break;
case 11:
System.out.println(“30”);
break;
case 12:
System.out.println(“31”);
break;
}
sc.close();
}
}

}

王者段位测试
package cn.ysq.day02;
import java.util.Scanner;

public class OperatoeDemo6 {
public static void main(String[] args){
Scanner sc = new Scanner (System.in);
System.out.println(“请输入你的分数:”);
int x =sc.nextInt();
if(x>=90 && x<=100){
System.out.println(“你是最强王者:”);
}
else if(x>=80 && x<90){
System.out.println(“你是星耀:”);
}
else if(x>=70 && x<80){
System.out.println(“你是钻石:”);
}
else if(x>=60 && x<70){
System.out.println(“你是黄金:”);
}
else if(x>=0 && x<60){
System.out.println(“你是黑铁:”);
}
sc.close();
}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值