对象的单体模式 为了解决箭头函数this指向的问题 推出来一种写法 对象的单体模式 面向对象 JavaScript 语言中,生成实例对象的传统方法是通过构造函数。 function Animal(name,age){ this.name = name; this.age = age; } // 为对 ...
分类:
其他好文 时间:
2019-01-12 13:11:07
阅读次数:
240
在年龄的基础上判定年龄是否为1`100之间,在就输出,否者手动抛出异常 package cn.kgc; /** *建立年龄类 */ public class Person { private int age; public int getAge() { return age; } public vo ...
分类:
编程语言 时间:
2019-01-12 13:09:37
阅读次数:
188
import settingimport hashlibimport timeclass People: def __init__(self, name, age, sex): self.id = self.create_id() self.name = name self.age = age se ...
分类:
其他好文 时间:
2019-01-11 22:16:10
阅读次数:
173
Unlucky year in Berland is such a year that its number n can be represented as n?=?xa?+?yb, where a and b are non-negative integer numbers. For exampl ...
分类:
其他好文 时间:
2019-01-11 22:14:10
阅读次数:
165
1.定义时不需要像C语言一样加 ' int ' , 'char ' 等,直接写即可,解释器会直接自动识别数据类型。例: age = 22 (默认为数字类型) name = 'Alex' (默认为字符串类型) 2.字符串类型:Python中,加了引号的都被认为是字符串! (1)单引号和双引号没区别,在 ...
分类:
其他好文 时间:
2019-01-11 20:06:39
阅读次数:
168
在编写个人函数的时候,你将受到C++中一条基本原则的限制:在默认的情况下,参数只能以值传递的方式给函数。这句话的理解是:被传递到函数的只是变量的值,永远不会是变量本身。举例如下: My age is 24 In this , my age is 25 Now my age is 24 请按任意键继续 ...
分类:
其他好文 时间:
2019-01-11 17:21:26
阅读次数:
212
#封装的意义:明确的区分内外,控制外部对隐藏属性的操作class People: def __init__(self, name, age): self.__name = name self.__age = age #print('名字是%s年纪是%s'%self.__name,self.__age ...
分类:
其他好文 时间:
2019-01-11 11:28:38
阅读次数:
255
有的时候我们经常需要把sql中的某个字段换成想要的值 或者说当某个字段为空值赋值为0或true 写一个简单的例子 第一种写法 select name,ifnull(age,'0'),adress from user 第二种写法 select name,case when age is null th ...
分类:
数据库 时间:
2019-01-11 11:24:46
阅读次数:
394
--创建表CREATE TABLE userinfo3 ( ID INT PRIMARY KEY NOT NULL, --ID 整数类型,设置为主键,并且不能为空 name VARCHAR ( 10 ) NOT NULL, --name 可变长度字符类型,不能为空 age INT NULL --ag... ...
分类:
数据库 时间:
2019-01-11 00:08:46
阅读次数:
166
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person. Person A will NOT friend request pers ...
分类:
移动开发 时间:
2019-01-11 00:05:29
阅读次数:
164