Java语言程序设计与数据结构(基础篇)课后练习题 第十三章(二)(1)

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip1024b (备注Java)
img

正文

stack.list = (ArrayList)list.clone();

return stack;

}

}

package dishisanzhang;

public class dishisanzhang {

public static void main(String[] args) throws CloneNotSupportedException {

MyStack stack = new MyStack();

for (int i = 0; i < 10; i++)

stack.push(i);

MyStack stack1 = (MyStack) stack.clone();

for (int i = 0; i < 10; i++)

stack1.pop();

System.out.println(stack.getSize());

System.out.println(stack1.getSize());

}

}

13.9

=================================================================

package dishisanzhang;

import java.util.Date;

public abstract class GeometricObject {

private String color;

private boolean filled;

private Date dateCreated;

protected GeometricObject() {

dateCreated = new Date();

}

protected GeometricObject(String color, boolean filled) {

this.color = color;

this.filled = filled;

dateCreated = new Date();

}

public String getColor() {

return color;

}

public void setColor(String color) {

this.color = color;

}

public boolean isFilled() {

return filled;

}

public void setFilled(boolean filled) {

this.filled = filled;

}

public Date getDateCreated() {

return dateCreated;

}

@Override

public String toString() {

return "Create on " + dateCreated + "\nColor: " + color + “\n and Filled” + filled;

}

public abstract double getArea();

public abstract double getPerimeter();

}

package dishisanzhang;

public class Circle extends GeometricObject implements Comparable< Circle > {

private double radius;

public Circle() {

}

public Circle(double radius) {

this(radius, “white”, false);

}

public Circle(double radius, String color, boolean filled) {

super(color, filled);

this.radius = radius;

}

public double getRadius() {

return radius;

}

@Override

public double getArea() {

return radius * radius * Math.PI;

}

@Override

public double getPerimeter() {

return 2 * radius * Math.PI;

}

@Override

public String toString() {

return "\nCircle Radius : " + getRadius();

}

@Override

public int compareTo(Circle c) {

if (getArea() < c.getArea())

return -1;

else if (getArea() > c.getArea())

return 1;

else

return 0;

}

@Override

public boolean equals(Object o) {

if (((Circle) o).getRadius() == radius)

return true;

else

return false;

}

}

package dishisanzhang;

public class dishisanzhang {

public static void main(String[] args) throws CloneNotSupportedException {

Circle c1 = new Circle(2);

Circle c2 = new Circle(3);

Circle c3 = new Circle(2);

System.out.println("c1 equals c2 ? " + c1.equals(c2));

System.out.println("c1 equals c3 ? " + c1.equals(c3));

}

}

13.10

==================================================================

package dishisanzhang;

import java.util.Date;

public abstract class GeometricObject {

private String color;

private boolean filled;

private Date dateCreated;

protected GeometricObject() {

dateCreated = new Date();

}

protected GeometricObject(String color, boolean filled) {

this.color = color;

this.filled = filled;

dateCreated = new Date();

}

public String getColor() {

return color;

}

public void setColor(String color) {

this.color = color;

}

public boolean isFilled() {

return filled;

}

public void setFilled(boolean filled) {

this.filled = filled;

}

public Date getDateCreated() {

return dateCreated;

}

@Override

public String toString() {

return "Create on " + dateCreated + "\nColor: " + color + “\n and Filled” + filled;

}

public abstract double getArea();

public abstract double getPerimeter();

}

package dishisanzhang;

public class Rectangle extends GeometricObject implements Comparable< Rectangle > {

private double width;

private double height;

public Rectangle() {

}

public Rectangle(double width, double height) {

this(width, height, “white”, false);

}

public Rectangle(double width, double height, String color, boolean filled) {

super(color, filled);

this.width = width;

this.height = height;

}

public double getWidth() {

return width;

}

public void setWidth(double width) {

this.width = width;

}

public double getHeight() {

return height;

}

public void setHeight(double height) {

this.height = height;

}

@Override

public double getArea() {

return width * height;

}

@Override

public double getPerimeter() {

return 2 * (width + height);

}

@Override

public int compareTo(Rectangle r) {

if (getArea() > r.getArea())

return 1;

else if (getArea() < r.getArea())

return -1;

else

return 0;

}

@Override

public boolean equals(Object o) {

if (compareTo((Rectangle) o) == 0)

return true;

else

return false;

}

}

package dishisanzhang;

public class dishisanzhang {

public static void main(String[] args) throws CloneNotSupportedException {

Rectangle r1 = new Rectangle(1,1);

Rectangle r2 = new Rectangle(2,3);

Rectangle r3 = new Rectangle(3,2);

System.out.println("r1 equals r2 ? " + r1.equals(r2));

System.out.println("r2 equals r3 ? " + r2.equals(r3));

}

}

13.11

==================================================================

package dishisanzhang;

import java.util.Date;

public abstract class GeometricObject {

private String color;

private boolean filled;

private Date dateCreated;

protected GeometricObject() {

dateCreated = new Date();

}

protected GeometricObject(String color, boolean filled) {

this.color = color;

this.filled = filled;

dateCreated = new Date();

}

public String getColor() {

return color;

}

public void setColor(String color) {

this.color = color;

}

public boolean isFilled() {

return filled;

}

public void setFilled(boolean filled) {

this.filled = filled;

}

public Date getDateCreated() {

return dateCreated;

}

@Override

public String toString() {

return "Create on " + dateCreated + "\nColor: " + color + “\n and Filled” + filled;

}

public abstract double getArea();

public abstract double getPerimeter();

}

package dishisanzhang;

public class Octagon extends GeometricObject implements Comparable< Octagon >, Cloneable {

private double side;

public Octagon() {

}

public Octagon(double side) {

this(side, “White”, false);

}

public Octagon(double side, String color, boolean filled) {

super(color, filled);

this.side = side;

}

public double getSide() {

return side;

}

public void setSide(double side) {

this.side = side;

}

@Override

public double getArea() {

return (2 + 4 * Math.sqrt(2)) * side * side;

}

@Override

public double getPerimeter() {

return 8 * side;

}

@Override

public String toString() {

return super.toString() + "\nside : " + side;

}

@Override

public int compareTo(Octagon octagon) {

if (getArea() > octagon.getArea())

return 1;

else if (getArea() < octagon.getArea())

return -1;

else

return 0;

}

@Override

public Object clone() {

try {

Octagon octagon = (Octagon) super.clone();

return octagon;

} catch (CloneNotSupportedException e) {

return null;

}

}

}

package dishisanzhang;

public class dishisanzhang {

public static void main(String[] args) throws CloneNotSupportedException {

Octagon o1 = new Octagon(2);

Octagon o2 = (Octagon)o1.clone();

System.out.println(o1.getArea());

最后

毕竟工作也这么久了 ,除了途虎一轮,也七七八八面试了不少大厂,像阿里、饿了么、美团、滴滴这些面试过程就不一一写在这篇文章上了。我会整理一份详细的面试过程及大家想知道的一些问题细节

美团面试经验

美团面试
字节面试经验
字节面试
菜鸟面试经验
菜鸟面试
蚂蚁金服面试经验
蚂蚁金服
唯品会面试经验
唯品会

因篇幅有限,图文无法详细发出

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

}

}

package dishisanzhang;

public class dishisanzhang {

public static void main(String[] args) throws CloneNotSupportedException {

Octagon o1 = new Octagon(2);

Octagon o2 = (Octagon)o1.clone();

System.out.println(o1.getArea());

最后

毕竟工作也这么久了 ,除了途虎一轮,也七七八八面试了不少大厂,像阿里、饿了么、美团、滴滴这些面试过程就不一一写在这篇文章上了。我会整理一份详细的面试过程及大家想知道的一些问题细节

美团面试经验

[外链图片转存中…(img-mJ9fXnh0-1713631100341)]
字节面试经验
[外链图片转存中…(img-GQCPVsK5-1713631100342)]
菜鸟面试经验
[外链图片转存中…(img-2TCXy4FW-1713631100342)]
蚂蚁金服面试经验
[外链图片转存中…(img-RBaDF8bN-1713631100343)]
唯品会面试经验
[外链图片转存中…(img-WS5sSn4k-1713631100343)]

因篇幅有限,图文无法详细发出

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
[外链图片转存中…(img-nVqGbjMF-1713631100344)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值