value in the class, but outside of the methods. You can access k in a method using self.k """ self.color = color def Hello1(self): print "Hello from Class1!" def printColor(self): """in this case self allows color to be passed""" print "I like the color", self.color def __localHello(self): """ A variable or function with a double underline prefix and no or max. single underline postfix is considered private to the class
; # The color blue is passed to __init__ () C1 = Class1 (' Blue ') # Class2 inherited Metho D __init__ () from Class1 # if you used C2 = Class2 (), the default color green would is picked C2 = Class2 (' red ') print '-' *20 print "Class1 says hello:" C1. Hello1 () print '-' *20 print ' Class2 says a Class1 hello: ' C2. Hello1 () print '-' *20 print ' Class2 says its own hello: C2. Hello2 () print '-' *Print "Class1 color via __init__ ():" C1.printcolor
abstract void Printcolor ();}Then create a new Audi car sub-category:Public class Audi extends car { /* * Automotive Sub Audi * In the construction of Audi car configuration related information * */public Audi () {Super.setcolor ("white");} @Overridepublic void Printcolor () {//TODO auto-generated method StubSystem.out.println ("Audi Car Color:" +super.getcolor ());}}Then create a new decorato
"Design pattern Refinement" Learning notes (10) ------Strategy (policy) mode
GoF : Define a series of algorithms, encapsulate them one by one, and allow them to replace each other. This mode allows the algorithm to vary independently from the customer who uses it.
For example, in our system, we need to paint a graphic or a WordArt (such a system is in the real world, a bill output system made by my former company has this function). If we need a variety of colors of graphics or WordArt, t
to reuse the business logic code in Class components. First, we will introduce how to adapt to Mixin. The following is an example of Mixin:
const someMixins={ printColor(){ console.log(this.state.color); } setColor(newColor){ this.setState({color:newColor}) } componentDidMount(){ .. }}
The following is a component using Mixin:
Class Apple extends react. component {// only for demonstration. mixins generally use react. createclass is cr
basic data type before JDK1.5 can now be resolved.
4. Enumeration:
Enumerations are the attributes that are needed in a comparison that JDK1.5 introduces. The keyword is an enumFor example: Define an enumeration representing traffic lights
public enum myenum{
Red,green,yellow
}
5. Variable parameters
What does that mean? First, for example: Before JDK1.5, when we were going to pass multiple types of identical parameters for a method, we had two solutions, 1. Pass
Js deep learning-differences between js prototype constructor attributes
In many js plug-ins, these two attributes are frequently used. I also used them when I write plug-ins myself. I know how to use them, but I don't know the specific differences. I have studied them today,
Constructor returns the constructor of an object (type instance). attributes and methods added through prototype are not returned.
Prototype returns a Type prototype that does not support post-dinner constructor.
Example:
Js deep learning-differences between js prototype constructor attributes-jsconstructor
In many js plug-ins, these two attributes are frequently used. I also used them when I write plug-ins myself. I know how to use them, but I don't know the specific differences. I have studied them today,
Constructor returns the constructor of an object (type instance). attributes and methods added through prototype are not returned.
Prototype returns a Type prototype that does not support post-dinner construct
1, JavaScript is often used in combination with HTML, use the following:
A:
B:
2, JavaScript does not have the concept of a block, all the variables in the function are global variables, even if you create in the IF, switch statements are also global variables, this is very different from other languages
Such as:
In the following example, the definition of color two times, which may cause some kind of error in other languages, but not in JS, but for the readability of the program, it is best n
Print"Hello World";5Self::printnewline ();6 }7 8 Static functionPrintnewline () {9 Echo Php_eol;Ten } One } AHelloWorld::SayHello (); -HelloWorld::SayHello (); -?>4, constants of the class> Global constants defined with the Define functionThe constants of the > class are similar to static members, and they belong to the class itself, not to instances of the classThe constants of the > class are case-sensitivePHPclassMycolorenumclass {Const
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.