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

建网站要多少钱一年广州最新政策

建网站要多少钱一年,广州最新政策,中国建设工程招标官方网站,哪个网站做网销更好本文章就讲的是很基础的类的使用 重点大概就是类的构造函数以及一些很基础的东西。 实验内容是些老生常谈的东西,Complex类,在当初学C面向对象的时候也是这个样子展开的。 内容如以下: public class Complex {float real;float imag;public…

本文章就讲的是很基础的类的使用
重点大概就是类的构造函数以及一些很基础的东西。

实验内容是些老生常谈的东西,Complex类,在当初学C++面向对象的时候也是这个样子展开的。
内容如以下:

public class Complex {float real;float imag;public Complex(){real = 0;imag = 0;}public Complex(float real, float imag){this.real = real;this.imag = imag;}public Complex add(float real){this.real += real;return this;}public Complex add(Complex complex){this.real += complex.real;this.imag += complex.imag;return this;}public Complex sub(float real){this.real -= real;return this;}public Complex sub(Complex complex){this.real -= complex.real;this.imag -= complex.imag;return this;}public Complex mul(float real){this.real *= real;this.imag *= real;return this;}public Complex mul(Complex complex){float TheReal = this.real;float TheImag = this.imag;this.real = TheReal * complex.real - TheImag*complex.imag;this.imag = TheReal * complex.imag + TheImag*complex.real;return this;}public String toString(){String str="";if(this.imag == 0){str += this.real;}else if(this.imag > 0 ){if(this.real==0){str += this.imag + "i";}else str += this.real + "+" + this.imag + "i";}else{if(this.real==0){str += this.imag + "i";}else str += this.real + "" + this.imag + "i";}return str;}}

这里也不得不说一丁点相关知识–重载 overload
如这里的:

	public Complex(){real = 0;imag = 0;}public Complex(float real, float imag){this.real = real;this.imag = imag;}public Complex add(float real){this.real += real;return this;}public Complex add(Complex complex){this.real += complex.real;this.imag += complex.imag;return this;}

这里的Complex()Complex(float real, float imag)构造函数也就用了一些重载的知识。
所谓重载,就是函数名不变但是函数内部的参数变化,我们调用函数时通过函数里面的参数决定我们要调用哪个函数。
同理的,Complex add(float real),Complex add(Complex complex)也是如此,当add()的括号里面是一个float值的时候调用Complex add(float real),括号里面是一个Complex对象的时候调用Complex add(Complex complex)
我当时认为这不是理所当然的吗?其实不是的,这里是用到了重载(overload)的知识。
总代码:
在这里插入图片描述

包com.Class.Work3里的Complex类:

package com.Class.Work3;public class Complex {float real;float imag;public Complex(){real = 0;imag = 0;}public Complex(float real, float imag){this.real = real;this.imag = imag;}public Complex add(float real){this.real += real;return this;}public Complex add(Complex complex){this.real += complex.real;this.imag += complex.imag;return this;}public Complex sub(float real){this.real -= real;return this;}public Complex sub(Complex complex){this.real -= complex.real;this.imag -= complex.imag;return this;}public Complex mul(float real){this.real *= real;this.imag *= real;return this;}public Complex mul(Complex complex){float TheReal = this.real;float TheImag = this.imag;this.real = TheReal * complex.real - TheImag*complex.imag;this.imag = TheReal * complex.imag + TheImag*complex.real;return this;}public String toString(){String str="";if(this.imag == 0){str += this.real;}else if(this.imag > 0 ){if(this.real==0){str += this.imag + "i";}else str += this.real + "+" + this.imag + "i";}else{if(this.real==0){str += this.imag + "i";}else str += this.real + "" + this.imag + "i";}return str;}}

调用Complex类的TestWork3类:

import com.Class.Work3.Complex;public class TestWork3 {public static void main(String[] args) {Complex c = new Complex(1, 2);
//        c.add(5);
//        Complex w = new Complex(4,1);
//        c.sub(w);
//        Complex w2 = new Complex(1,2);
//        c.mul(w2);
//        c.mul(5);System.out.println(c);}
}

就这样了~

http://www.hkea.cn/news/964110/

相关文章:

  • 汽车网站正在建设中模板什么是营销模式
  • 宜昌seo百度seo优化
  • 做网站公司q房网seo快速排名站外流量推广
  • 南宁网站排名优化广州发布紧急通知
  • 网站建设的策划方案seo排名
  • 网站模板绑定域名培训班
  • coupang入驻条件2022台州关键词优化报价
  • 网站建设前景怎么样google优化师
  • 上海免费网站建设淘宝引流推广怎么做
  • 单位网站建设目的西安网站建设公司排行榜
  • 福州制作网站软件无人在线观看高清视频单曲直播
  • 建设银行卡网站百度账号登录个人中心
  • 网站显示500错误怎么解决方法seo网站推广排名
  • 广告免费设计在线生成网站排名优化
  • 余姚公司网站建设怎么建网址
  • 网站域名授权怎么做市场营销案例100例
  • kindeditor代码高亮 wordpressseo优化排名经验
  • 家乡介绍网页设计上海网站排名优化
  • 广州黄埔网站制作百度sem是什么意思
  • 网站流量分析网站网络推广营销网
  • 化妆品网站建设计划书网站维护是什么意思
  • 建设局网站公告宣传推广的形式有哪些
  • 网站基本架构设计的主要步骤什么软件可以排名次
  • 代做毕业设计网站多少钱网站推广交换链接
  • 苹果指争议广告lg广告北京seo公司网站
  • flash网站制作公司能打开各种网站的浏览器下载
  • 网站开发是叫系统吗站长工具seo排名查询
  • 站长之家html模板西安网站seo技术厂家
  • 重庆网站建设 渝seo交流论坛
  • 洛阳市网站建设宁波seo网络推广软件系统