继承关系
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":702,"y":249,"rotation":0,"id":78,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":70,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[82,-4],[50,-4],[50,-69.32485578727801],[18,-69.32485578727801]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":70,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":32,"px":0.9999999999999998,"py":0.7071067811865475}}},"linkMap":[]},{"x":615,"y":70,"rotation":0,"id":77,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":69,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[169,6.75],[137,6.75],[137,70.32485578727798],[105,70.32485578727798]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":63,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":32,"px":1,"py":0.29289321881345237}}},"linkMap":[]},{"x":228,"y":356,"rotation":0,"id":55,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[202,-46],[202,-22.666666666666686],[202,0.6666666666666856],[202,24]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":24,"px":0.5,"py":1}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":48,"px":0.5,"py":0}}},"linkMap":[]},{"x":667,"y":225,"rotation":0,"id":47,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":40,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-17,-17.5],[-17,8.333333333333343],[-17,34.166666666666686],[-17,60]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":32,"px":0.5,"py":1}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":56,"px":0.5,"py":0}}},"linkMap":[]},{"x":403,"y":390,"rotation":0,"id":39,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":39,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[97,-125],[137,-125],[137,-230],[177,-230]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":24,"px":1,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":32,"px":0,"py":0.5}}},"linkMap":[]},{"x":289,"y":219,"rotation":0,"id":31,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[141,1],[141,-124],[51,-124]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":24,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":0,"px":1,"py":0.5}}},"linkMap":[]},{"x":325,"y":185,"rotation":0,"id":22,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-55,35],[-55,11.666666666666657],[-55,-11.666666666666657],[-55,-35]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":14,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":0,"px":0.5,"py":1}}},"linkMap":[]},{"x":98,"y":173,"rotation":0,"id":21,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":22,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[12,47],[12,-78],[102,-78]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":7,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":0,"px":0,"py":0.5}}},"linkMap":[]},{"x":200,"y":220,"rotation":0,"id":14,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":15,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":15,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":16,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"Teacher
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":16,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":17,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":18,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"title
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":15,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":18,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":19,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":20,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"teach
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":14,"magnitude":1},{"id":15,"magnitude":-1},{"id":17,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":17,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":15,"magnitude":1},{"id":17,"magnitude":1},{"id":20,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":40,"y":220,"rotation":0,"id":7,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":8,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":8,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":9,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"Student
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":9,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":10,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":11,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"grade
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":8,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":11,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":12,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":13,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"study
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":7,"magnitude":1},{"id":8,"magnitude":-1},{"id":10,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":10,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":8,"magnitude":1},{"id":10,"magnitude":1},{"id":13,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":200,"y":40,"rotation":0,"id":0,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":110,"lockAspectRatio":false,"lockShape":false,"order":1,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":1,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":2,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"Person
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":2,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":3,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":4,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"name\n
age
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":1,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":4,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":5,"uid":null,"width":140,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":6,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"eat\n
play
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":0,"magnitude":1},{"id":1,"magnitude":-1},{"id":3,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":3,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":1,"magnitude":1},{"id":3,"magnitude":1},{"id":6,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":360,"y":220,"rotation":0,"id":24,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":90,"lockAspectRatio":false,"lockShape":false,"order":24,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":25,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":26,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"Driver
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":26,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":27,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":28,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"work_experience\n
license
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":25,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":28,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":29,"uid":null,"width":140,"height":40,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":30,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"drive
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":24,"magnitude":1},{"id":25,"magnitude":-1},{"id":27,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":27,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":25,"magnitude":1},{"id":27,"magnitude":1},{"id":30,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":580,"y":112.5,"rotation":0,"id":32,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":95,"lockAspectRatio":false,"lockShape":false,"order":32,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":33,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":34,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"Vehicle
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":34,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":35,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":36,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"brand\n
engine
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":33,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":36,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":37,"uid":null,"width":140,"height":45,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":38,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"accelerate\n
slow_down
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":32,"magnitude":1},{"id":33,"magnitude":-1},{"id":35,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":35,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":33,"magnitude":1},{"id":35,"magnitude":1},{"id":38,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":360,"y":380,"rotation":0,"id":48,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":41,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":49,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":50,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"License
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":50,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":51,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":52,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"Attribute
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":49,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":52,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":53,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":54,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"Method
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":48,"magnitude":1},{"id":49,"magnitude":-1},{"id":51,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":51,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":49,"magnitude":1},{"id":51,"magnitude":1},{"id":54,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":580,"y":285,"rotation":0,"id":56,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":48,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":57,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":58,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"Engine
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":58,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":59,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":60,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"number
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":57,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":60,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":61,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":62,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":56,"magnitude":1},{"id":57,"magnitude":-1},{"id":59,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":59,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":57,"magnitude":1},{"id":59,"magnitude":1},{"id":62,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":784,"y":41,"rotation":0,"id":63,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":71.5,"lockAspectRatio":false,"lockShape":false,"order":55,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":64,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":65,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"
Car
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":65,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":66,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":67,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"seats\n
displacement
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":64,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":67,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":68,"uid":null,"width":140,"height":21.5,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":69,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":63,"magnitude":1},{"id":64,"magnitude":-1},{"id":66,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":66,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":64,"magnitude":1},{"id":66,"magnitude":1},{"id":69,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":784,"y":207.5,"rotation":0,"id":70,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":62,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":71,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":72,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"
Truck
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":72,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":73,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":74,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"capacity
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":71,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":74,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":75,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":76,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":70,"magnitude":1},{"id":71,"magnitude":-1},{"id":73,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":73,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":71,"magnitude":1},{"id":73,"magnitude":1},{"id":76,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":371,"y":346,"rotation":0,"id":81,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":60,"height":14,"lockAspectRatio":false,"lockShape":false,"order":72,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"
关联关系
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":490,"y":186.5,"rotation":0,"id":82,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":60,"height":14,"lockAspectRatio":false,"lockShape":false,"order":73,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"依赖关系
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":591,"y":238,"rotation":0,"id":83,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":60,"height":14,"lockAspectRatio":false,"lockShape":false,"order":74,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"聚合关系
","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]}],"background":"#FFFFFF","width":926,"height":455,"maxWidth":5000,"maxHeight":5000,"nodeIndex":84,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file diff --git a/Day09/res/uml-example.png b/Day09/res/uml-example.png deleted file mode 100644 index 14e8e9c37..000000000 Binary files a/Day09/res/uml-example.png and /dev/null differ diff --git a/Day09/shape.py b/Day09/shape.py deleted file mode 100644 index 8bd292c26..000000000 --- a/Day09/shape.py +++ /dev/null @@ -1,66 +0,0 @@ -""" - -继承的应用 - - 抽象类 - - 抽象方法 - - 方法重写 - - 多态 - -Version: 0.1 -Author: 骆昊 -Date: 2018-03-12 - -""" - -from abc import ABCMeta, abstractmethod -from math import pi - - -class Shape(object, metaclass=ABCMeta): - - @abstractmethod - def perimeter(self): - pass - - @abstractmethod - def area(self): - pass - - -class Circle(Shape): - - def __init__(self, radius): - self._radius = radius - - def perimeter(self): - return 2 * pi * self._radius - - def area(self): - return pi * self._radius ** 2 - - def __str__(self): - return '我是一个圆' - - -class Rect(Shape): - - def __init__(self, width, height): - self._width = width - self._height = height - - def perimeter(self): - return 2 * (self._width + self._height) - - def area(self): - return self._width * self._height - - def __str__(self): - return '我是一个矩形' - - -if __name__ == '__main__': - shapes = [Circle(5), Circle(3.2), Rect(3.2, 6.3)] - for shape in shapes: - print(shape) - print('周长:', shape.perimeter()) - print('面积:', shape.area()) diff --git a/Day09/triangle.py b/Day09/triangle.py deleted file mode 100644 index d6feb762d..000000000 --- a/Day09/triangle.py +++ /dev/null @@ -1,53 +0,0 @@ -""" - -实例方法和类方法的应用 - -Version: 0.1 -Author: 骆昊 -Date: 2018-03-12 - -""" - -from math import sqrt - - -class Triangle(object): - - def __init__(self, a, b, c): - self._a = a - self._b = b - self._c = c - - # 静态方法 - @staticmethod - def is_valid(a, b, c): - return a + b > c and b + c > a and c + a > b - - # 实例方法 - def perimeter(self): - return self._a + self._b + self._c - - # 实例方法 - def area(self): - p = self.perimeter() / 2 - return sqrt(p * (p - self._a) * (p - self._b) * (p - self._c)) - - -if __name__ == '__main__': - # 用字符串的split方法将字符串拆分成一个列表 - # 再通过map函数对列表中的每个字符串进行映射处理成小数 - a, b, c = map(float, input('请输入三条边: ').split()) - # 先判断给定长度的三条边能否构成三角形 - # 如果能才创建三角形对象 - if Triangle.is_valid(a, b, c): - tri = Triangle(a, b, c) - print('周长:', tri.perimeter()) - print('面积:', tri.area()) - # 如果传入对象作为方法参数也可以通过类调用实例方法 - # print('周长:', Triangle.perimeter(tri)) - # print('面积:', Triangle.area(tri)) - # 看看下面的代码就知道其实二者本质上是一致的 - # print(type(tri.perimeter)) - # print(type(Triangle.perimeter)) - else: - print('不能构成三角形.') diff --git "a/Day09/\351\235\242\345\220\221\345\257\271\350\261\241\350\277\233\351\230\266.md" "b/Day09/\351\235\242\345\220\221\345\257\271\350\261\241\350\277\233\351\230\266.md" deleted file mode 100644 index 836f22bad..000000000 --- "a/Day09/\351\235\242\345\220\221\345\257\271\350\261\241\350\277\233\351\230\266.md" +++ /dev/null @@ -1,766 +0,0 @@ -## 面向对象进阶 - -在前面的章节我们已经了解了面向对象的入门知识,知道了如何定义类,如何创建对象以及如何给对象发消息。为了能够更好的使用面向对象编程思想进行程序开发,我们还需要对Python中的面向对象编程进行更为深入的了解。 - -### @property装饰器 - -之前我们讨论过Python中属性和方法访问权限的问题,虽然我们不建议将属性设置为私有的,但是如果直接将属性暴露给外界也是有问题的,比如我们没有办法检查赋给属性的值是否有效。我们之前的建议是将属性命名以单下划线开头,通过这种方式来暗示属性是受保护的,不建议外界直接访问,那么如果想访问属性可以通过属性的getter(访问器)和setter(修改器)方法进行对应的操作。如果要做到这点,就可以考虑使用@property包装器来包装getter和setter方法,使得对属性的访问既安全又方便,代码如下所示。 - -```Python -class Person(object): - - def __init__(self, name, age): - self._name = name - self._age = age - - # 访问器 - getter方法 - @property - def name(self): - return self._name - - # 访问器 - getter方法 - @property - def age(self): - return self._age - - # 修改器 - setter方法 - @age.setter - def age(self, age): - self._age = age - - def play(self): - if self._age <= 16: - print('%s正在玩飞行棋.' % self._name) - else: - print('%s正在玩斗地主.' % self._name) - - -def main(): - person = Person('王大锤', 12) - person.play() - person.age = 22 - person.play() - # person.name = '白元芳' # AttributeError: can't set attribute - - -if __name__ == '__main__': - main() - -``` - -### \_\_slots\_\_魔法 - -我们讲到这里,不知道大家是否已经意识到,Python是一门[动态语言](https://zh.wikipedia.org/wiki/%E5%8A%A8%E6%80%81%E8%AF%AD%E8%A8%80)。通常,动态语言允许我们在程序运行时给对象绑定新的属性或方法,当然也可以对已经绑定的属性和方法进行解绑定。但是如果我们需要限定自定义类型的对象只能绑定某些属性,可以通过在类中定义\_\_slots\_\_变量来进行限定。需要注意的是\_\_slots\_\_的限定只对当前类的对象生效,对子类并不起任何作用。 - -```Python -class Person(object): - - # 限定Person对象只能绑定_name, _age和_gender属性 - __slots__ = ('_name', '_age', '_gender') - - def __init__(self, name, age): - self._name = name - self._age = age - - @property - def name(self): - return self._name - - @property - def age(self): - return self._age - - @age.setter - def age(self, age): - self._age = age - - def play(self): - if self._age <= 16: - print('%s正在玩飞行棋.' % self._name) - else: - print('%s正在玩斗地主.' % self._name) - - -def main(): - person = Person('王大锤', 22) - person.play() - person._gender = '男' - # AttributeError: 'Person' object has no attribute '_is_gay' - # person._is_gay = True - -``` - -### 静态方法和类方法 - -之前,我们在类中定义的方法都是对象方法,也就是说这些方法都是发送给对象的消息。实际上,我们写在类中的方法并不需要都是对象方法,例如我们定义一个“三角形”类,通过传入三条边长来构造三角形,并提供计算周长和面积的方法,但是传入的三条边长未必能构造出三角形对象,因此我们可以先写一个方法来验证三条边长是否可以构成三角形,这个方法很显然就不是对象方法,因为在调用这个方法时三角形对象尚未创建出来(因为都不知道三条边能不能构成三角形),所以这个方法是属于三角形类而并不属于三角形对象的。我们可以使用静态方法来解决这类问题,代码如下所示。 - -```Python -from math import sqrt - - -class Triangle(object): - - def __init__(self, a, b, c): - self._a = a - self._b = b - self._c = c - - @staticmethod - def is_valid(a, b, c): - return a + b > c and b + c > a and a + c > b - - def perimeter(self): - return self._a + self._b + self._c - - def area(self): - half = self.perimeter() / 2 - return sqrt(half * (half - self._a) * - (half - self._b) * (half - self._c)) - - -def main(): - a, b, c = 3, 4, 5 - # 静态方法和类方法都是通过给类发消息来调用的 - if Triangle.is_valid(a, b, c): - t = Triangle(a, b, c) - print(t.perimeter()) - # 也可以通过给类发消息来调用对象方法但是要传入接收消息的对象作为参数 - # print(Triangle.perimeter(t)) - print(t.area()) - # print(Triangle.area(t)) - else: - print('无法构成三角形.') - - -if __name__ == '__main__': - main() - -``` - -和静态方法比较类似,Python还可以在类中定义类方法,类方法的第一个参数约定名为cls,它代表的是当前类相关的信息的对象(类本身也是一个对象,有的地方也称之为类的元数据对象),通过这个参数我们可以获取和类相关的信息并且可以创建出类的对象,代码如下所示。 - -```Python -from time import time, localtime, sleep - - -class Clock(object): - """数字时钟""" - - def __init__(self, hour=0, minute=0, second=0): - self._hour = hour - self._minute = minute - self._second = second - - @classmethod - def now(cls): - ctime = localtime(time()) - return cls(ctime.tm_hour, ctime.tm_min, ctime.tm_sec) - - def run(self): - """走字""" - self._second += 1 - if self._second == 60: - self._second = 0 - self._minute += 1 - if self._minute == 60: - self._minute = 0 - self._hour += 1 - if self._hour == 24: - self._hour = 0 - - def show(self): - """显示时间""" - return '%02d:%02d:%02d' % \ - (self._hour, self._minute, self._second) - - -def main(): - # 通过类方法创建对象并获取系统时间 - clock = Clock.now() - while True: - print(clock.show()) - sleep(1) - clock.run() - - -if __name__ == '__main__': - main() - -``` - -### 类之间的关系 - -简单的说,类和类之间的关系有三种:is-a、has-a和use-a关系。 - -- is-a关系也叫继承或泛化,比如学生和人的关系、手机和电子产品的关系都属于继承关系。 -- has-a关系通常称之为关联,比如部门和员工的关系,汽车和引擎的关系都属于关联关系;关联关系如果是整体和部分的关联,那么我们称之为聚合关系;如果整体进一步负责了部分的生命周期(整体和部分是不可分割的,同时同在也同时消亡),那么这种就是最强的关联关系,我们称之为合成关系。 -- use-a关系通常称之为依赖,比如司机有一个驾驶的行为(方法),其中(的参数)使用到了汽车,那么司机和汽车的关系就是依赖关系。 - -我们可以使用一种叫做[UML](https://zh.wikipedia.org/wiki/%E7%BB%9F%E4%B8%80%E5%BB%BA%E6%A8%A1%E8%AF%AD%E8%A8%80)(统一建模语言)的东西来进行面向对象建模,其中一项重要的工作就是把类和类之间的关系用标准化的图形符号描述出来。关于UML我们在这里不做详细的介绍,有兴趣的读者可以自行阅读[《UML面向对象设计基础》](https://e.jd.com/30392949.html)一书。 - - - - - -利用类之间的这些关系,我们可以在已有类的基础上来完成某些操作,也可以在已有类的基础上创建新的类,这些都是实现代码复用的重要手段。复用现有的代码不仅可以减少开发的工作量,也有利于代码的管理和维护,这是我们在日常工作中都会使用到的技术手段。 - -### 继承和多态 - -刚才我们提到了,可以在已有类的基础上创建新类,这其中的一种做法就是让一个类从另一个类那里将属性和方法直接继承下来,从而减少重复代码的编写。提供继承信息的我们称之为父类,也叫超类或基类;得到继承信息的我们称之为子类,也叫派生类或衍生类。子类除了继承父类提供的属性和方法,还可以定义自己特有的属性和方法,所以子类比父类拥有的更多的能力,在实际开发中,我们经常会用子类对象去替换掉一个父类对象,这是面向对象编程中一个常见的行为,对应的原则称之为[里氏替换原则](https://zh.wikipedia.org/wiki/%E9%87%8C%E6%B0%8F%E6%9B%BF%E6%8D%A2%E5%8E%9F%E5%88%99)。下面我们先看一个继承的例子。 - -```Python -class Person(object): - """人""" - - def __init__(self, name, age): - self._name = name - self._age = age - - @property - def name(self): - return self._name - - @property - def age(self): - return self._age - - @age.setter - def age(self, age): - self._age = age - - def play(self): - print('%s正在愉快的玩耍.' % self._name) - - def watch_av(self): - if self._age >= 18: - print('%s正在观看爱情动作片.' % self._name) - else: - print('%s只能观看《熊出没》.' % self._name) - - -class Student(Person): - """学生""" - - def __init__(self, name, age, grade): - super().__init__(name, age) - self._grade = grade - - @property - def grade(self): - return self._grade - - @grade.setter - def grade(self, grade): - self._grade = grade - - def study(self, course): - print('%s的%s正在学习%s.' % (self._grade, self._name, course)) - - -class Teacher(Person): - """老师""" - - def __init__(self, name, age, title): - super().__init__(name, age) - self._title = title - - @property - def title(self): - return self._title - - @title.setter - def title(self, title): - self._title = title - - def teach(self, course): - print('%s%s正在讲%s.' % (self._name, self._title, course)) - - -def main(): - stu = Student('王大锤', 15, '初三') - stu.study('数学') - stu.watch_av() - t = Teacher('骆昊', 38, '老叫兽') - t.teach('Python程序设计') - t.watch_av() - - -if __name__ == '__main__': - main() - -``` - -子类在继承了父类的方法后,可以对父类已有的方法给出新的实现版本,这个动作称之为方法重写(override)。通过方法重写我们可以让父类的同一个行为在子类中拥有不同的实现版本,当我们调用这个经过子类重写的方法时,不同的子类对象会表现出不同的行为,这个就是多态(poly-morphism)。 - -```Python -from abc import ABCMeta, abstractmethod - - -class Pet(object, metaclass=ABCMeta): - """宠物""" - - def __init__(self, nickname): - self._nickname = nickname - - @abstractmethod - def make_voice(self): - """发出声音""" - pass - - -class Dog(Pet): - """狗""" - - def make_voice(self): - print('%s: 汪汪汪...' % self._nickname) - - -class Cat(Pet): - """猫""" - - def make_voice(self): - print('%s: 喵...喵...' % self._nickname) - - -def main(): - pets = [Dog('旺财'), Cat('凯蒂'), Dog('大黄')] - for pet in pets: - pet.make_voice() - - -if __name__ == '__main__': - main() - -``` - -在上面的代码中,我们将`Pet`类处理成了一个抽象类,所谓抽象类就是不能够创建对象的类,这种类的存在就是专门为了让其他类去继承它。Python从语法层面并没有像Java或C#那样提供对抽象类的支持,但是我们可以通过`abc`模块的`ABCMeta`元类和`abstractmethod`包装器来达到抽象类的效果,如果一个类中存在抽象方法那么这个类就不能够实例化(创建对象)。上面的代码中,`Dog`和`Cat`两个子类分别对`Pet`类中的`make_voice`抽象方法进行了重写并给出了不同的实现版本,当我们在`main`函数中调用该方法时,这个方法就表现出了多态行为(同样的方法做了不同的事情)。 - -### 综合案例 - -#### 案例1:奥特曼打小怪兽 - -```Python -from abc import ABCMeta, abstractmethod -from random import randint, randrange - - -class Fighter(object, metaclass=ABCMeta): - """战斗者""" - - # 通过__slots__魔法限定对象可以绑定的成员变量 - __slots__ = ('_name', '_hp') - - def __init__(self, name, hp): - """ - 初始化方法 - - :param name: 名字 - :param hp: 生命值 - """ - self._name = name - self._hp = hp - - @property - def name(self): - return self._name - - @property - def hp(self): - return self._hp - - @hp.setter - def hp(self, hp): - self._hp = hp if hp >= 0 else 0 - - @property - def alive(self): - return self._hp > 0 - - @abstractmethod - def attack(self, other): - """ - 攻击 - - :param other: 被攻击的对象 - """ - pass - - -class Ultraman(Fighter): - """奥特曼""" - - __slots__ = ('_name', '_hp', '_mp') - - def __init__(self, name, hp, mp): - """ - 初始化方法 - - :param name: 名字 - :param hp: 生命值 - :param mp: 魔法值 - """ - super().__init__(name, hp) - self._mp = mp - - def attack(self, other): - other.hp -= randint(15, 25) - - def huge_attack(self, other): - """ - 究极必杀技(打掉对方至少50点或四分之三的血) - - :param other: 被攻击的对象 - - :return: 使用成功返回True否则返回False - """ - if self._mp >= 50: - self._mp -= 50 - injury = other.hp * 3 // 4 - injury = injury if injury >= 50 else 50 - other.hp -= injury - return True - else: - self.attack(other) - return False - - def magic_attack(self, others): - """ - 魔法攻击 - - :param others: 被攻击的群体 - - :return: 使用魔法成功返回True否则返回False - """ - if self._mp >= 20: - self._mp -= 20 - for temp in others: - if temp.alive: - temp.hp -= randint(10, 15) - return True - else: - return False - - def resume(self): - """恢复魔法值""" - incr_point = randint(1, 10) - self._mp += incr_point - return incr_point - - def __str__(self): - return '~~~%s奥特曼~~~\n' % self._name + \ - '生命值: %d\n' % self._hp + \ - '魔法值: %d\n' % self._mp - - -class Monster(Fighter): - """小怪兽""" - - __slots__ = ('_name', '_hp') - - def attack(self, other): - other.hp -= randint(10, 20) - - def __str__(self): - return '~~~%s小怪兽~~~\n' % self._name + \ - '生命值: %d\n' % self._hp - - -def is_any_alive(monsters): - """判断有没有小怪兽是活着的""" - for monster in monsters: - if monster.alive > 0: - return True - return False - - -def select_alive_one(monsters): - """选中一只活着的小怪兽""" - monsters_len = len(monsters) - while True: - index = randrange(monsters_len) - monster = monsters[index] - if monster.alive > 0: - return monster - - -def display_info(ultraman, monsters): - """显示奥特曼和小怪兽的信息""" - print(ultraman) - for monster in monsters: - print(monster, end='') - - -def main(): - u = Ultraman('骆昊', 1000, 120) - m1 = Monster('舒小玲', 250) - m2 = Monster('白元芳', 500) - m3 = Monster('王大锤', 750) - ms = [m1, m2, m3] - fight_round = 1 - while u.alive and is_any_alive(ms): - print('========第%02d回合========' % fight_round) - m = select_alive_one(ms) # 选中一只小怪兽 - skill = randint(1, 10) # 通过随机数选择使用哪种技能 - if skill <= 6: # 60%的概率使用普通攻击 - print('%s使用普通攻击打了%s.' % (u.name, m.name)) - u.attack(m) - print('%s的魔法值恢复了%d点.' % (u.name, u.resume())) - elif skill <= 9: # 30%的概率使用魔法攻击(可能因魔法值不足而失败) - if u.magic_attack(ms): - print('%s使用了魔法攻击.' % u.name) - else: - print('%s使用魔法失败.' % u.name) - else: # 10%的概率使用究极必杀技(如果魔法值不足则使用普通攻击) - if u.huge_attack(m): - print('%s使用究极必杀技虐了%s.' % (u.name, m.name)) - else: - print('%s使用普通攻击打了%s.' % (u.name, m.name)) - print('%s的魔法值恢复了%d点.' % (u.name, u.resume())) - if m.alive > 0: # 如果选中的小怪兽没有死就回击奥特曼 - print('%s回击了%s.' % (m.name, u.name)) - m.attack(u) - display_info(u, ms) # 每个回合结束后显示奥特曼和小怪兽的信息 - fight_round += 1 - print('\n========战斗结束!========\n') - if u.alive > 0: - print('%s奥特曼胜利!' % u.name) - else: - print('小怪兽胜利!') - - -if __name__ == '__main__': - main() - -``` - -#### 案例2:扑克游戏 - -```Python -from random import randrange - - -class Card(object): - """一张牌""" - - def __init__(self, suite, face): - self._suite = suite - self._face = face - - @property - def face(self): - return self._face - - @property - def suite(self): - return self._suite - - def __str__(self): - all_suites = ('♠', '♥', '♣', '♦') - if self._face == 1: - face_str = 'A' - elif self._face == 11: - face_str = 'J' - elif self._face == 12: - face_str = 'Q' - elif self._face == 13: - face_str = 'K' - else: - face_str = str(self._face) - return '%s%s' % (all_suites[self._suite], face_str) - - -class Poker(object): - """一副牌""" - - def __init__(self): - self._cards = [] - self._current = 0 - for suite in range(4): - for face in range(1, 14): - card = Card(suite, face) - self._cards.append(card) - - @property - def cards(self): - return self._cards - - def shuffle(self): - """洗牌(随机乱序)""" - self._current = 0 - cards_len = len(self._cards) - for index in range(cards_len): - pos = randrange(cards_len) - self._cards[index], self._cards[pos] = \ - self._cards[pos], self._cards[index] - - @property - def next(self): - """发牌""" - card = self._cards[self._current] - self._current += 1 - return card - - @property - def has_next(self): - """还有没有牌""" - return self._current < len(self._cards) - - -class Player(object): - """玩家""" - - def __init__(self, name): - self._name = name - self._cards_on_hand = [] - - @property - def name(self): - return self._name - - @property - def cards_on_hand(self): - return self._cards_on_hand - - def get(self, card): - """摸牌""" - self._cards_on_hand.append(card) - - def arrange(self, card_key): - """玩家整理手上的牌""" - self._cards_on_hand.sort(key=card_key) - - -# 排序规则-先根据花色再根据点数排序 -def get_key(card): - return (card.suite, card.face) - - -def main(): - p = Poker() - p.shuffle() - players = [Player('东邪'), Player('西毒'), Player('南帝'), Player('北丐')] - for _ in range(13): - for player in players: - player.get(p.next) - for player in players: - print(player.name + ':', end=' ') - player.arrange(get_key) - for card in player.cards_on_hand: - print(card, end=' ') - print() - - -if __name__ == '__main__': - main() - -``` - ->**说明**:大家可以自己尝试在上面代码的基础上写一个简单的扑克游戏,例如21点(Black Jack),游戏的规则可以自己在网上找一找。 - -#### 案例3:工资结算系统 - -```Python -""" - -某公司有三种类型的员工 分别是部门经理、程序员和销售员 -需要设计一个工资结算系统 根据提供的员工信息来计算月薪 -部门经理的月薪是每月固定15000元 -程序员的月薪按本月工作时间计算 每小时150元 -销售员的月薪是1200元的底薪加上销售额5%的提成 - -""" -from abc import ABCMeta, abstractmethod - - -class Employee(object, metaclass=ABCMeta): - """员工""" - - def __init__(self, name): - """ - 初始化方法 - - :param name: 姓名 - """ - self._name = name - - @property - def name(self): - return self._name - - @abstractmethod - def get_salary(self): - """ - 获得月薪 - - :return: 月薪 - """ - pass - - -class Manager(Employee): - """部门经理""" - - def get_salary(self): - return 15000.0 - - -class Programmer(Employee): - """程序员""" - - def __init__(self, name, working_hour=0): - super().__init__(name) - self._working_hour = working_hour - - @property - def working_hour(self): - return self._working_hour - - @working_hour.setter - def working_hour(self, working_hour): - self._working_hour = working_hour if working_hour > 0 else 0 - - def get_salary(self): - return 150.0 * self._working_hour - - -class Salesman(Employee): - """销售员""" - - def __init__(self, name, sales=0): - super().__init__(name) - self._sales = sales - - @property - def sales(self): - return self._sales - - @sales.setter - def sales(self, sales): - self._sales = sales if sales > 0 else 0 - - def get_salary(self): - return 1200.0 + self._sales * 0.05 - - -def main(): - emps = [ - Manager('刘备'), Programmer('诸葛亮'), - Manager('曹操'), Salesman('荀彧'), - Salesman('吕布'), Programmer('张辽'), - Programmer('赵云') - ] - for emp in emps: - if isinstance(emp, Programmer): - emp.working_hour = int(input('请输入%s本月工作时间: ' % emp.name)) - elif isinstance(emp, Salesman): - emp.sales = float(input('请输入%s本月销售额: ' % emp.name)) - # 同样是接收get_salary这个消息但是不同的员工表现出了不同的行为(多态) - print('%s本月工资为: ¥%s元' % - (emp.name, emp.get_salary())) - - -if __name__ == '__main__': - main() - -``` - diff --git a/Day10/ball.py b/Day10/ball.py deleted file mode 100644 index 3d5369561..000000000 --- a/Day10/ball.py +++ /dev/null @@ -1,109 +0,0 @@ -from enum import Enum, unique -from math import sqrt -from random import randint - -import pygame - - -@unique -class Color(Enum): - """颜色""" - - RED = (255, 0, 0) - GREEN = (0, 255, 0) - BLUE = (0, 0, 255) - BLACK = (0, 0, 0) - WHITE = (255, 255, 255) - GRAY = (242, 242, 242) - - @staticmethod - def random_color(): - """获得随机颜色""" - r = randint(0, 255) - g = randint(0, 255) - b = randint(0, 255) - return (r, g, b) - - -class Ball(object): - """球""" - - def __init__(self, x, y, radius, sx, sy, color=Color.RED): - """初始化方法""" - self.x = x - self.y = y - self.radius = radius - self.sx = sx - self.sy = sy - self.color = color - self.alive = True - - def move(self, screen): - """移动""" - self.x += self.sx - self.y += self.sy - if self.x - self.radius <= 0 or self.x + self.radius >= screen.get_width(): - self.sx = -self.sx - if self.y - self.radius <= 0 or self.y + self.radius >= screen.get_height(): - self.sy = -self.sy - - def eat(self, other): - """吃其他球""" - if self.alive and other.alive and self != other: - dx, dy = self.x - other.x, self.y - other.y - distance = sqrt(dx ** 2 + dy ** 2) - if distance < self.radius + other.radius \ - and self.radius > other.radius: - other.alive = False - self.radius = self.radius + int(other.radius * 0.146) - - def draw(self, screen): - """在窗口上绘制球""" - pygame.draw.circle(screen, self.color, - (self.x, self.y), self.radius, 0) - - -def main(): - # 定义用来装所有球的容器 - balls = [] - # 初始化导入的pygame中的模块 - pygame.init() - # 初始化用于显示的窗口并设置窗口尺寸 - screen = pygame.display.set_mode((800, 600)) - print(screen.get_width()) - print(screen.get_height()) - # 设置当前窗口的标题 - pygame.display.set_caption('大球吃小球') - # 定义变量来表示小球在屏幕上的位置 - x, y = 50, 50 - running = True - # 开启一个事件循环处理发生的事件 - while running: - # 从消息队列中获取事件并对事件进行处理 - for event in pygame.event.get(): - if event.type == pygame.QUIT: - running = False - if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: - x, y = event.pos - radius = randint(10, 100) - sx, sy = randint(-10, 10), randint(-10, 10) - color = Color.random_color() - ball = Ball(x, y, radius, sx, sy, color) - balls.append(ball) - screen.fill((255, 255, 255)) - for ball in balls: - if ball.alive: - ball.draw(screen) - else: - balls.remove(ball) - pygame.display.flip() - # 每隔50毫秒就改变小球的位置再刷新窗口 - pygame.time.delay(50) - for ball in balls: - ball.move(screen) - for other in balls: - ball.eat(other) - - -if __name__ == '__main__': - main() diff --git a/Day10/gui1.py b/Day10/gui1.py deleted file mode 100644 index 6eb747bd8..000000000 --- a/Day10/gui1.py +++ /dev/null @@ -1,57 +0,0 @@ -""" - -使用tkinter创建GUI - - 顶层窗口 - - 控件 - - 布局 - - 事件回调 - -Version: 0.1 -Author: 骆昊 -Date: 2018-03-14 - -""" - -import tkinter -import tkinter.messagebox - - -def main(): - flag = True - - # 修改标签上的文字 - def change_label_text(): - nonlocal flag - flag = not flag - color, msg = ('red', 'Hello, world!')\ - if flag else ('blue', 'Goodbye, world!') - label.config(text=msg, fg=color) - - # 确认退出 - def confirm_to_quit(): - if tkinter.messagebox.askokcancel('温馨提示', '确定要退出吗?'): - top.quit() - - # 创建顶层窗口 - top = tkinter.Tk() - # 设置窗口大小 - top.geometry('240x160') - # 设置窗口标题 - top.title('小游戏') - # 创建标签对象 - label = tkinter.Label(top, text='Hello, world!', font='Arial -32', fg='red') - label.pack(expand=1) - # 创建一个装按钮的容器 - panel = tkinter.Frame(top) - # 创建按钮对象 - button1 = tkinter.Button(panel, text='修改', command=change_label_text) - button1.pack(side='left') - button2 = tkinter.Button(panel, text='退出', command=confirm_to_quit) - button2.pack(side='right') - panel.pack(side='bottom') - # 开启主事件循环 - tkinter.mainloop() - - -if __name__ == '__main__': - main() diff --git a/Day10/gui2.py b/Day10/gui2.py deleted file mode 100644 index 69c81d0da..000000000 --- a/Day10/gui2.py +++ /dev/null @@ -1,43 +0,0 @@ -""" - -使用tkinter创建GUI - - 使用画布绘图 - - 处理鼠标事件 - -Version: 0.1 -Author: 骆昊 -Date: 2018-03-14 - -""" - -import tkinter - - -def mouse_evt_handler(evt=None): - row = round((evt.y - 20) / 40) - col = round((evt.x - 20) / 40) - pos_x = 40 * col - pos_y = 40 * row - canvas.create_oval(pos_x, pos_y, 40 + pos_x, 40 + pos_y, fill='black') - - -top = tkinter.Tk() -# 设置窗口尺寸 -top.geometry('620x620') -# 设置窗口标题 -top.title('五子棋') -# 设置窗口大小不可改变 -top.resizable(False, False) -# 设置窗口置顶 -top.wm_attributes('-topmost', 1) -canvas = tkinter.Canvas(top, width=600, height=600, bd=0, highlightthickness=0) -canvas.bind('- | 成都 | -北京 | -杭州 | -
Python从入门到住院全国巡演 | -2018年2月28日 上午9:30 | -2018年3月28日 上午9:30 | -2018年4月28日 上午9:30 | -
MySQL从删库到跑路公开课 | -2018年2月27日 上午9:30 | -2018年3月5日 上午9:30 | -2018年4月2日 上午9:30 | -
Django从学习到上吊交流会 | -2018年2月28日 上午9:30 | -- | 2018年5月21日 上午9:30 | -
爬虫从精通到坐牢无遮大会 | -2018年3月3日 上午9:30 | -2018年4月17日 上午9:30 | -2018年1月15日 上午9:30 | -
One | +Two | +
---|---|
Three | +Four | +
Five | +Six | +
Seven | +Eight | +
Nine | +Ten | +
Eleven | +Twelve | +