当前位置: 首页 > news >正文

河北邯郸中考成绩查询网站wordpress cdn评论不能显示

河北邯郸中考成绩查询网站,wordpress cdn评论不能显示,泰安网站建设哪家快,做网站的骗术实验名称 实验二 类与对象 实验目的 1. 深刻理解类的封装与继承#xff1b; 2. 熟练掌握类的定义、包与路径、对象的创建、方法的调用、类的继承、方法的重写、运行时多态、访问权限修饰符的使用等#xff1b; 3. 熟练运用JDK提供的常用类及API。 实验内容…实验名称    实验二 类与对象 实验目的    1. 深刻理解类的封装与继承 2. 熟练掌握类的定义、包与路径、对象的创建、方法的调用、类的继承、方法的重写、运行时多态、访问权限修饰符的使用等 3. 熟练运用JDK提供的常用类及API。   实验内容4学时 1. 定义一个圆形类Circle包括 1属性圆心、半径 2方法求面积、周长上下左右平移缩放绘图虚拟表示。 设计测试类CircleDemo在测试类中测试上述方法。以后实验中均自行设计测试类。 class Circle {private double centerX;private double centerY;private double radius;public Circle(double centerX, double centerY, double radius) {this.centerX centerX;this.centerY centerY;this.radius radius;}public double getArea() {return Math.PI * radius * radius;}public double getPerimeter() {return 2 * Math.PI * radius;}public void translate(double deltaX, double deltaY) {centerX deltaX;centerY deltaY;}public void scale(double factor) {radius * factor;}public void draw() {System.out.println(Drawing a circle at ( centerX , centerY ) with radius radius);} }public class CircleDemo {public static void main(String[] args) {Circle circle new Circle(0, 0, 5.0);System.out.println(Area: circle.getArea());System.out.println(Perimeter: circle.getPerimeter());circle.translate(2.0, 3.0);circle.scale(1.5);circle.draw();} } 2. 设计Bird类包括1属性name2方法fly( )fly方法以及后面提到的各种方法均以字符串输出来演示功能。 以Bird类为超类父类设计子类CarrierPigeon 1为CarrierPigeon类新增方法send(String address, String message) 2在CarrierPigeon 覆盖 Bird 的 fly() 方法 public class Bird {private String name;public Bird(String name) {this.name name;}public String getName() {return name;}public void fly() {System.out.println(name is flying.);} }public class CarrierPigeon extends Bird {public CarrierPigeon(String name) {super(name);}public void send(String address, String message) {System.out.println(getName() is sending a message to address : message);}Overridepublic void fly() {System.out.println(getName() is flying with a message.);} }public class BirdDemo {public static void main(String[] args) {Bird bird new Bird(Sparrow);bird.fly();CarrierPigeon pigeon new CarrierPigeon(Pigeon);pigeon.fly();pigeon.send(Recipient, Important message);} } 3. Java编程实现设计复数类Complex类中实部和虚部都是实数实现加法、减法、乘法和除法。 public class Complex {private double real;private double imaginary;public Complex(double real, double imaginary) {this.real real;this.imaginary imaginary;}public Complex add(Complex other) {double newReal this.real other.real;double newImaginary this.imaginary other.imaginary;return new Complex(newReal, newImaginary);}public Complex subtract(Complex other) {double newReal this.real - other.real;double newImaginary this.imaginary - other.imaginary;return new Complex(newReal, newImaginary);}public Complex multiply(Complex other) {double newReal this.real * other.real - this.imaginary * other.imaginary;double newImaginary this.real * other.imaginary this.imaginary * other.real;return new Complex(newReal, newImaginary);}public Complex divide(Complex other) {double denominator other.real * other.real other.imaginary * other.imaginary;double newReal (this.real * other.real this.imaginary * other.imaginary) / denominator;double newImaginary (this.imaginary * other.real - this.real * other.imaginary) / denominator;return new Complex(newReal, newImaginary);}Overridepublic String toString() {return real imaginary i;} }public class ComplexDemo {public static void main(String[] args) {Complex c1 new Complex(2.0, 3.0);Complex c2 new Complex(1.0, 1.0);Complex sum c1.add(c2);Complex difference c1.subtract(c2);Complex product c1.multiply(c2);Complex quotient c1.divide(c2);System.out.println(Sum: sum);System.out.println(Difference: difference);System.out.println(Product: product);System.out.println(Quotient: quotient);} } 4. Java编程实现设计矩阵类Matrix类中的方法能对矩阵进行加法、减法和乘法运算。在矩阵中再定义一个方法生成如下的矩阵 public class Matrix {private int[][] data;public Matrix(int[][] data) {this.data data;}// 获取矩阵的行数public int getRows() {return data.length;}// 获取矩阵的列数public int getColumns() {return data[0].length;}// 矩阵加法public Matrix add(Matrix other) {if (getRows() ! other.getRows() || getColumns() ! other.getColumns()) {throw new IllegalArgumentException(矩阵维度不匹配);}int[][] result new int[getRows()][getColumns()];for (int i 0; i getRows(); i) {for (int j 0; j getColumns(); j) {result[i][j] data[i][j] other.data[i][j];}}return new Matrix(result);}// 矩阵减法public Matrix subtract(Matrix other) {if (getRows() ! other.getRows() || getColumns() ! other.getColumns()) {throw new IllegalArgumentException(矩阵维度不匹配);}int[][] result new int[getRows()][getColumns()];for (int i 0; i getRows(); i) {for (int j 0; j getColumns(); j) {result[i][j] data[i][j] - other.data[i][j];}}return new Matrix(result);}// 矩阵乘法public Matrix multiply(Matrix other) {if (getColumns() ! other.getRows()) {throw new IllegalArgumentException(矩阵维度不匹配);}int[][] result new int[getRows()][other.getColumns()];for (int i 0; i getRows(); i) {for (int j 0; j other.getColumns(); j) {int sum 0;for (int k 0; k getColumns(); k) {sum data[i][k] * other.data[k][j];}result[i][j] sum;}}return new Matrix(result);}// 生成指定的矩阵public static Matrix createMatrixE() {int[][] eMatrixData {{1, 3, 8, 7, 5, 6},{3, 8, 7, 5, 6, 1},{8, 7, 5, 6, 1, 3},{7, 5, 6, 1, 3, 8},{5, 6, 1, 3, 8, 7},{6, 1, 3, 8, 7, 5}};return new Matrix(eMatrixData);}// 打印矩阵public void printMatrix() {for (int i 0; i getRows(); i) {for (int j 0; j getColumns(); j) {System.out.print(data[i][j] );}System.out.println();}}public static void main(String[] args) {Matrix matrixE createMatrixE();System.out.println(Matrix E:);matrixE.printMatrix();Matrix matrixA new Matrix(new int[][] {{1, 2, 3},{4, 5, 6},{7, 8, 9}});Matrix matrixB new Matrix(new int[][] {{9, 8, 7},{6, 5, 4},{3, 2, 1}});System.out.println(\nMatrix A:);matrixA.printMatrix();System.out.println(\nMatrix B:);matrixB.printMatrix();Matrix matrixSum matrixA.add(matrixB);System.out.println(\nMatrix A B:);matrixSum.printMatrix();Matrix matrixDifference matrixA.subtract(matrixB);System.out.println(\nMatrix A - B:);matrixDifference.printMatrix();Matrix matrixProduct matrixA.multiply(matrixB);System.out.println(\nMatrix A * B:);matrixProduct.printMatrix();} } 实验程序及结果附录 思考 以C为代表的结构化编程语言和以Java为代表的面向对象编程语言有哪些本质不同 关于结构化编程语言以C为代表和面向对象编程语言以Java为代表的本质不同 抽象与封装面向对象编程强调对象的抽象和封装允许将数据和操作封装在对象内部提供更好的信息隐藏和模块化。结构化编程相对较少使用对象更多地依赖于函数和数据的分离。继承与多态面向对象编程支持继承和多态允许创建层次结构的类重用代码并实现多态性。结构化编程通常较少使用这些概念更注重逻辑流程和模块化设计。对象面向对象编程以对象为中心将数据和操作封装在对象中。结构化编程更倾向于使用数据结构和函数。设计模式面向对象编程强调设计模式例如单例模式、工厂模式等以提供更好的可维护性和可扩展性。结构化编程通常较少使用这些模式。类型系统面向对象编程通常有更强的类型系统支持多态和动态绑定。结构化编程的类型系统通常较为简单。 总之面向对象编程更注重数据和操作的封装、继承、多态等概念而结构化编程更注重逻辑流程和分离数据和函数。不同编程范式适用于不同类型的问题和项目。
http://www.pierceye.com/news/253488/

相关文章:

  • 网站备案的网站名称分类信息网址
  • 教育类网站建站jae安装wordpress
  • wordpress自定义站点设计网站广告语
  • 广告型网站怎么做的网络技术学习网站
  • 网站建设公司不赚钱进一步推进网站建设
  • 四川省工程建设协会网站360路由器网站建设
  • 快云服务器怎么做网站360网站收录提交入口大全
  • 网站设计的安全尺寸正规的培训行业网站开发
  • 网站提交了被收录后改怎么做商丘网站制作教程
  • 建网站被封了网站建设网页设计小江
  • 用node做的网站索引网站有哪些
  • 无锡设计网站建设时尚杂志网站设计分析
  • 嘉定区网站建设网站建设怎么谈
  • 网站开发 毕业设计如何做网站app
  • 优惠券网站开发谷歌seo搜索引擎下载
  • 安徽省建设工程资料上传网站重庆相亲网
  • 河南建设网站官网中英文公司网站
  • 手机版网站如何建设会议响应式网站开发
  • 肇庆住房建设部网站国外专门做旅游攻略的网站
  • 网站如何设置长尾词静态网站开发一体化课程
  • 学校网站建设流程做网站用哪个工具
  • 网站开发工作室策划案域名的价格
  • 郑州艾特网站建设公司互联网保险图片
  • 网站后台任务网站设计建设一般多少钱
  • 电子商务网站设计的基本流程创业商机网农村
  • 公司网站建设的费用如何入账毕节网站开发公司电话
  • 新浪推网站蜘蛛网站长工作职责
  • 百度网站排名关键词整站优化将wordpress部署
  • 做的ASP网站手机微站和网站数据同步
  • 爱站网长尾关键词挖掘工具营销类型网站怎么建设