pangyaxuan
|
c46c70540f
|
删除 'W5/屏幕截图 2026-04-06 201413.png'
|
2 weeks ago |
pangyaxuan
|
8a75d6c21b
|
上传文件至 'W5(2)'
package w5;
// 基础题:Shape类及其子类
abstract class Shape {
public abstract void draw();
}
class Circle extends Shape {
private double r;
public Circle(double r) {
this.r = r;
}
@Override
public void draw() {
System.out.println("绘制圆形,半径:" + r);
}
}
class Rectangle extends Shape {
private double width;
private double height;
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
@Override
public void draw() {
System.out.println("绘制矩形,宽:" + width + ",高:" + height);
}
}
// 工具类
class ShapeUtil {
public static void drawShape(Shape s) {
s.draw();
}
}
// 主类
public class PolymorphismDemo {
public static void main(String[] args) {
System.out.println("=== 基础题测试 ===");
// 测试Shape类
Shape circle = new Circle(5);
Shape rectangle = new Rectangle(4, 6);
ShapeUtil.drawShape(circle);
ShapeUtil.drawShape(rectangle);
}
}
|
2 weeks ago |
pangyaxuan
|
76f43bdf17
|
上传文件至 'W5'
package w5;
// 基础题:Shape类及其子类
abstract class Shape {
public abstract void draw();
}
class Circle extends Shape {
private double r;
public Circle(double r) {
this.r = r;
}
@Override
public void draw() {
System.out.println("绘制圆形,半径:" + r);
}
}
class Rectangle extends Shape {
private double width;
private double height;
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
@Override
public void draw() {
System.out.println("绘制矩形,宽:" + width + ",高:" + height);
}
}
// 工具类
class ShapeUtil {
public static void drawShape(Shape s) {
s.draw();
}
}
// 主类
public class PolymorphismDemo {
public static void main(String[] args) {
System.out.println("=== 基础题测试 ===");
// 测试Shape类
Shape circle = new Circle(5);
Shape rectangle = new Rectangle(4, 6);
ShapeUtil.drawShape(circle);
ShapeUtil.drawShape(rectangle);
}
}
|
2 weeks ago |
pangyaxuan
|
309d1bc0a9
|
Merge pull request '删除 'W5/NeteaseCommentCrawler.java'' (#4) from delete-w5-file into main
Reviewed-on: #4
|
2 weeks ago |
pangyaxuan
|
8a87c62002
|
删除 'W5/NeteaseCommentCrawler.java'
|
2 weeks ago |
pangyaxuan
|
92e49b2f14
|
上传文件至 'W5'
package w5;
// 基础题:Shape类及其子类
abstract class Shape {
public abstract void draw();
}
class Circle extends Shape {
private double r;
public Circle(double r) {
this.r = r;
}
@Override
public void draw() {
System.out.println("绘制圆形,半径:" + r);
}
}
class Rectangle extends Shape {
private double width;
private double height;
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
@Override
public void draw() {
System.out.println("绘制矩形,宽:" + width + ",高:" + height);
}
}
// 工具类
class ShapeUtil {
public static void drawShape(Shape s) {
s.draw();
}
}
// 主类
public class PolymorphismDemo {
public static void main(String[] args) {
System.out.println("=== 基础题测试 ===");
// 测试Shape类
Shape circle = new Circle(5);
Shape rectangle = new Rectangle(4, 6);
ShapeUtil.drawShape(circle);
ShapeUtil.drawShape(rectangle);
}
}
|
2 weeks ago |
pangyaxuan
|
d01244e8e8
|
上传文件至 'W4'
// 抽象图形类
abstract class Shape {
public abstract double getArea();
}
// 圆形
class Circle extends Shape {
private double r;
public Circle(double r) {
this.r = r;
}
@Override
public double getArea() {
return Math.PI * r * r;
}
}
// 矩形
class Rectangle extends Shape {
private double width;
private double height;
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
@Override
public double getArea() {
return width * height;
}
}
// 三角形
class Triangle extends Shape {
private double base;
private double height;
public Triangle(double base, double height) {
this.base = base;
this.height = height;
}
@Override
public double getArea() {
return 0.5 * base * height;
}
}
// 工具类
class ShapeUtil {
public static void printArea(Shape shape) {
System.out.println("面积:" + shape.getArea());
}
}
|
3 weeks ago |
pangyaxuan
|
63e1ed4f7c
|
删除 'W4'
|
3 weeks ago |
pangyaxuan
|
2b616b1f2d
|
添加 'W4'
|
3 weeks ago |
pangyaxuan
|
5c46764251
|
添加 'W3'
|
4 weeks ago |
pangyaxuan
|
2427675ea3
|
添加 'W2'
|
1 month ago |
pangyaxuan
|
1d1ed1a611
|
上传文件至 ''
|
1 month ago |
pangyaxuan
|
b1475a7060
|
删除 '屏幕截图 2026-03-09 003508.png'
|
1 month ago |
pangyaxuan
|
877089d100
|
删除 'TemperatureConverter.java'
|
1 month ago |
pangyaxuan
|
7b79b578f3
|
删除 'README.'
|
1 month ago |
pangyaxuan
|
5f47745086
|
添加 'README.'
|
1 month ago |
pangyaxuan
|
d8e0055ddc
|
上传文件至 ''
|
1 month ago |
pangyaxuan
|
046af68582
|
添加 'TemperatureConverter.java'
|
1 month ago |
pangyaxuan
|
b058787b27
|
添加 'hello wo r l d'
|
1 month ago |
hewh
|
3bebb701fa
|
Initial commit
|
2 months ago |