JavaScript 面向对象的编程 (Code with mosh学习笔记)

news2024/9/21 16:31:10

JavaScript OOP

Getting Start - 1- What is OOP

  • 面向对象的编程是一种编程范例
  • 围绕对象而不是函数
  • 一些OOP语言
    • C#
    • Java
    • Ruby
    • Python
    • JavaScript

Getting Start - 2- Four Pillars of OOP

OOP的4个概念:

  • 封装
    • 使用封装重新组合相关的变量和函数
    • 减少复杂性
    • 增加代码的可复用性
  • 抽象
    • 通过抽象隐藏细节和复杂性
    • 隔离了代码更改的影响
  • 继承
    • 继承可以消除冗余代码
  • 多态
    • 多态可以避免写出复杂的选择性代码

Getting Start - 3- Setting Up the Development Environment

  • 软件:vscode
  • 插件:Live Server

Objects - 1- Introduction

在这里插入图片描述

Objects - 2- Object Literals

const circle = {
    radius: 1,
    location: {
        x: 1,
        y: 1
    },
    draw: function() {
        console.log('draw');
    }
};

circle.draw();

Objects - 3- Factories

function createCircle(radius) {
    return {
        radius,
        draw: function() {
            console.log('draw');
        }
    }
}

const circle = createCircle(1);
circle.draw();

Objects - 4- Constructors

function Circle(radius) {
    this.radius = radius;
    this.draw = function() {
        console.log('draw');
    }
}
const another = new Circle(1);

Objects - 5- Constructor Property

每个对象都有一个构造函数属性 (.constructor),该属性引用了用来创建这个对象的构造函数

Objects - 7- Value vs Reference Types

在这里插入图片描述

Objects - 8- Adding or Removing Properties

function Circle(radius) {
    this.radius = radius;
    this.draw = function() {
        console.log('draw');
    }
}

const circle = new Circle(1);

circle.location = { x: 1 };

const pName = 'center location';
circle[pName] = { x: 2};

delete circle['location'];

console.log(circle);

Objects - 9- Enumerating Properties

function Circle(radius) {
    this.radius = radius;
    this.draw = function() {
        console.log('draw');
    }
}

const circle = new Circle(1);

for (let key in circle) {
    console.log(key, circle[key]);
}

Objects - 11- Private Properties and Methods

function Circle(radius) {
    this.radius = radius;

    this.defaultLocation = { x:0, y:0 };

    this.computeOptimumLocation = function(factor) {
        // ...
    };

    this.draw = function() {
        this.computeOptimumLocation(0.1);
        
        console.log('draw');
    };
}

const circle = new Circle(10);
function Circle(radius) {
    this.radius = radius;
    // 将过程变量和函数设为本地变量和本地函数,而不是对象的属性与方法(抽象)
    let defaultLocation = { x:0, y:0 };

    let computeOptimumLocation = function(factor) {
        // ...
    };

    this.draw = function() {
        computeOptimumLocation(0.1);

        console.log('draw');
    };
}

const circle = new Circle(10);

Objects - 12- Getters and Setters

function Circle(radius) {
    this.radius = radius;

    let defaultLocation = { x:0, y:0 };

    let computeOptimumLocation = function(factor) {
        // ...
    };

    this.draw = function() {
        computeOptimumLocation(0.1);
        console.log('draw');
    };

    // 通过defineProperty的方式,设置getter和setter
    Object.defineProperty(this, 'defaultLocation', {
        get: function() {
            return defaultLocation;
        },
        set: function(value) {
            if (!value.x || !value.y)
                throw new Error('Invalid location.');
            defaultLocation = value;    
        }
    });
}

const circle = new Circle(10);
circle.defaultLocation = {x:10,y:100};
console.log(circle.defaultLocation);

Objects - 14- Exercise- Stopwatch

function StopWatch() {
    let startTime, endTime, running, duration = 0;

    this.start = function() {
        if (running)
            throw new Error('Already running')
        
        running = true;
        startTime = new Date();
    };

    this.stop = function() {
        if (!running)
            throw new Error('Not running')

        running = false;
        endTime = new Date();
    };

    this.reset = function() {
        running = false;
        startTime = 0;
        endTime = 0;
        duration = 0;
    };

    Object.defineProperty(this, 'duration', {
        get: function() {
            return parseInt(endTime - startTime) / 1000;
        }
    });
}

sw = new StopWatch();

Prototypes - 1- Inheritance

在这里插入图片描述

Prototypes - 2- Prototypes and Prototypical Inheritance

在这里插入图片描述

  • 当访问一个对象的成员时,js引擎会沿着原型链路一直找,直到找到为止
  • 原型也是一般的对象
  • js中创建的对象都直接或间接的继承自元对象
  • 在内存中只有一个元对象的实例
let x = {};
let y = {};

console.log(Object.getPrototypeOf(x) === Object.getPrototypeOf(y));

Prototypes - 3- Multilevel Inheritance

在这里插入图片描述

  • 如果对象由给定的构造函数创造,那么它们拥有同一个原型

Prototypes - 4- Property Descriptors

let person = { name: 'Mosh' };

Object.defineProperty(person, 'name', {
    // 将name改为不可写入,不可配置
    writable: false,
    enumerable: true,
    configurable: false
});

person.name = 'John';
delete person.name;
console.log(person);

Prototypes - 5- Constructor Prototypes

对象. __ proto __ = 构造函数.prototype

// myObi.__proto__ (parent of myObj)
// Constructor.prototype (parent of myObj)
let obj = {};
console.log(obj.__proto__);
console.log(Object.prototype);

Prototypes - 6- Prototype vs Instance Members

function Circle(radius) {
    // Instance members
    this.radius = radius;

    this.move = function() {
        this.draw();
        console.log('move');
    }
}

// Prototype members
Circle.prototype.draw = function() {
    console.log('draw');
}

// 就近原则
Circle.prototype.toString = function() {
    return 'Circle with radius '+ this.radius;
}

const c1 = new Circle(1);
c1.move();
console.log(c1.toString());

Prototypes - 7- Iterating Instance and Prototype Members

  • Object.keys 只返回实例的成员
  • for in 循环返回所有的成员
function Circle(radius) {
    // Instance members
    this.radius = radius;

    this.move = function() {
        this.draw();
        console.log('move');
    }
}

// Prototype members
Circle.prototype.draw = function() {
    console.log('draw');
}

// 就近原则
Circle.prototype.toString = function() {
    return 'Circle with radius '+ this.radius;
}

const c1 = new Circle(1);

// Return instance members
console.log(Object.keys(c1));

// Return all members (instance + prototype)
for (let key in c1) console.log(key);

console.log(c1.hasOwnProperty('move'));
console.log(c1.hasOwnProperty('draw'));

Prototypes - 8- Avoid Extending the Built-in Objects

不要修改不属于你的对象

Prototypes - 10- Exercise

function StopWatch() {
    this.startTime = 0; 
    this.endTime = 0; 
    this.running = 0; 
    this.duration = 0;

    Object.defineProperty(this, 'duration', {
        get: function() {
            return parseInt(this.endTime - this.startTime) / 1000;
        }
    });
}

StopWatch.prototype.start = function() {
    if (this.running)
        throw new Error('Already running')
        
    this.running = true;
    this.startTime = new Date();
}

StopWatch.prototype.stop = function() {
    if (!this.running)
        throw new Error('Not running')

    this.running = false;
    this.endTime = new Date();
};

StopWatch.prototype.reset = function() {
    this.running = false;
    this.startTime = 0;
    this.endTime = 0;
    this.duration = 0;
};

sw = new StopWatch();

Prototypes Inheritance - 1- Creating Your Own Prototypical Inheritance

function Shape() {
}

Shape.prototype.duplicate = function() {
    console.log('duplicate');
}

function Circle(radius) {
    this.radius = radius;
}

Circle.prototype = Object.create(Shape.prototype);

Circle.prototype.draw = function() {
    console.log('draw');
}

const s = new Shape();
const c = new Circle(1);

c.duplicate();
c.draw();

Prototypes Inheritance - 2- Resetting the Constructor

当重设原型对象之后,应该同时重设属性构造器

function Shape() {
}

Shape.prototype.duplicate = function() {
    console.log('duplicate');
}

function Circle(radius) {
    this.radius = radius;
}

// 当重设原型对象之后,应该同时重设属性构造器
// Circle.prototype.constructor = Circle;
// new Circle.prototype.constructor() <=> new Circle(); 即可以通过prototype的constructor方法创建对象
Circle.prototype = Object.create(Shape.prototype);
Circle.prototype.constructor = Circle;

Circle.prototype.draw = function() {
    console.log('draw');
}

const c = new Circle(1);

console.log(c.constructor);

Prototypes Inheritance - 3- Calling the Super Constructor

function Shape(color) {
    this.color = color;
}

Shape.prototype.duplicate = function() {
    console.log('duplicate');
}

function Circle(radius, color) {
    // Child对象设置Parent对象的参数
    Shape.call(this, color);

    this.radius = radius;
}

Circle.prototype = Object.create(Shape.prototype);
Circle.prototype.constructor = Circle;

Circle.prototype.draw = function() {
    console.log('draw');
}

const c = new Circle(1, 'red');

console.log(c);

Prototypes Inheritance - 4- Intermediate Function Inheritance

// 继承函数的写法
function extend(Child, Parent) {
    Child.prototype = Object.create(Parent.prototype);
    Child.prototype.constructor = Child;
}

function Shape(color) {
    this.color = color;
}

Shape.prototype.duplicate = function() {
    console.log('duplicate');
}

function Circle(radius, color) {
    Shape.call(this, color);

    this.radius = radius;
}

extend(Circle, Shape);

Circle.prototype.draw = function() {
    console.log('draw');
}

const c = new Circle(1, 'red');

console.log(c);

Prototypes Inheritance - 5- Method Overriding

function extend(Child, Parent) {
    Child.prototype = Object.create(Parent.prototype);
    Child.prototype.constructor = Child;
}

function Shape(color) {
    this.color = color;
}

Shape.prototype.duplicate = function() {
    console.log('duplicate');
}

function Circle() {
}

extend(Circle, Shape);

// 方法的重写
Circle.prototype.duplicate = function() {
    Shape.prototype.duplicate.call(this);

    console.log('duplicate circle');
}

const c = new Circle();
c.duplicate();

Prototypes Inheritance - 6- Polymorphism

function extend(Child, Parent) {
    Child.prototype = Object.create(Parent.prototype);
    Child.prototype.constructor = Child;
}

function Shape(color) {
    this.color = color;
}

Shape.prototype.duplicate = function() {
    console.log('duplicate');
}

function Circle() {
}

extend(Circle, Shape);

Circle.prototype.duplicate = function() {
    console.log('duplicate circle');
}

function Square() {
}

extend(Square, Shape);

Square.prototype.duplicate = function() {
    console.log('duplicate square');
}

const shapes = [
    new Circle(),
    new Square()
];

for (let shape of shapes)
    shape.duplicate();

Prototypes Inheritance - 7- When to Use Inheritance

在这里插入图片描述

  • 应避免创建层级式继承关系
  • 好的组合胜过继承

Prototypes Inheritance - 8- Mixins

function mixin(target, ...sources) {
    Object.assign(target, ...sources);
}

const canEat = {
    eat: function() {
        this.hunger--;
        console.log('eating');
    }
};

const canWalk = {
    walk: function() {
        console.log('walking');
    }
};

const canSwim = {
    swim: function() {
        console.log('swimming')
    }
};

function Person() {
}
mixin(Person.prototype, canEat, canWalk);

function Goldfish() {
}
mixin(Goldfish.prototype, canEat, canSwim);

const person = new Person();
const goldfish = new Goldfish();

console.log(person);
console.log(goldfish);

Prototypes Inheritance - 9- Exercise- Prototypical Inheritance

function HtmlElement() {
    this.click = function() {
        console.log('clicked');
    } 
}
HtmlElement.prototype.focus = function() {
    console.log('focused')
};

function HtlmSearchElemen(items = []) {
    this.items = items;

    this.addItem = function(item) {
        this.items.push(item);
    };

    this.removeItem = function(item) {
        this.items.filter(v => v!==item);
        // this.items.splice(this.items.indexOf(item), 1);
    }
}
// 若采用 HtlmSearchElemen.prototype = Object.create(HtmlElement.prototype); 只能继承baseHtmlElemenr,无法继承click方法
HtlmSearchElemen.prototype = new HtmlElement();
HtlmSearchElemen.prototype.constructor = HtlmSearchElemen;

const e = new HtmlElement();
const se = new HtlmSearchElemen();

Prototypes Inheritance - 11- Exercise- Polymorphism

// HtmlElement
function HtmlElement() {
    this.click = function() {
        console.log('clicked');
    } 
}
HtmlElement.prototype.focus = function() {
    console.log('focused')
};

// HtlmSearchElemen
function HtlmSearchElemen(items = []) {
    this.items = items;

    this.addItem = function(item) {
        this.items.push(...item);
    };

    this.removeItem = function(item) {
        this.items.splice(this.items.indexOf(item), 1);
    }

    this.render = function() {
        s =  this.items.map(item => '<option>'+item+'</option>').join('\n'+'  ');
        s = `<select> \n  ${s}\n<select>`;
        return s;
        // another way
//         return `
// <select>${this.items.map(item => `
//   <option>${item}</option>`).join('')}
// </select>`;
//     }
}

HtlmSearchElemen.prototype = new HtmlElement();
HtlmSearchElemen.prototype.constructor = HtlmSearchElemen;

// HtmlImageElement
function HtmlImageElement(src = '') {
    this.src = src;

    this.render = function() {
        return `<img src="${this.src}"/>`;
    }
}
HtmlImageElement.prototype = new HtmlElement();
HtmlImageElement.prototype.constructor = HtmlImageElement;

const elements = [
    new HtlmSearchElemen([1,2,3]),
    new HtmlImageElement('https://')
];

for (let ele of elements)
    console.log(ele.render());

ES6 Classes - 1- ES6 Classes

class Circle {
    constructor(radius) {
        this.radius = radius;
        this.move = function() {}
    }

    draw() {
        console.log('draw');
    }
}

const c = new Circle(1);

ES6 Classes - 2- Hoisting

  • 函数声明会置顶(可以在定义之前被引用),函数表达式不会
// Class Declaration
class Circle {
}

// Class Expression
const Square = class{
};

ES6 Classes - 3- Static Methods

// 利用静态方法的方式创建不属于具体实例的工具函数
class Circle {
    constructor(radius) {
        this.radius = radius;
    }

    // Instance Method
    draw() {
    }

    // Static Method
    static parse(str) {
        const radius = JSON.parse(str).radius;
        return new Circle(radius);
    }
}

const circle = Circle.parse('{"radius": 1}');
console.log(circle);

ES6 Classes - 4- The This Keyword

class Circle {
    draw() {
        console.log(this);
    }
}

const c = new Circle();
// Method Call
c.draw();

// Function Call
const draw = c.draw;
draw();

ES6 Classes - 5- Private Members Using Symbols

// 利用Symbol来隐藏某些属性和方法(使其名称不可见,无法调用)
const _radius = Symbol();
const _draw = Symbol();

class Circle {
    constructor(radius) {
        this[_radius] = radius;
    }

    [_draw]() {
    }
}

const c = new Circle(1);

// 如果非要调用
const key = Object.getOwnPropertySymbols(c)[0];
console.log(c[key]);

ES6 Classes - 6- Private Members Using WeakMaps

const _radius = new WeakMap();
const _move = new WeakMap();

class Circle {
    constructor(radius) {
        _radius.set(this, radius);

        _move.set(this, () => {
            console.log('move', this);
        });
    }

    draw() {
        _move.get(this)();

        console.log('draw');
    }
}

const c = new Circle(1);
c.draw();

ES6 Classes - 7- Getters and Setters

const _radius = new WeakMap();

class Circle {
    constructor(radius) {
        _radius.set(this, radius);
    }

    get radius() {
        return _radius.get(this);
    }

    set radius(value) {
        if (value <= 0) throw new Error('invalid radius');
        _radius.set(this, value);
    }
    
}

const c = new Circle(1);
console.log(c.radius);

ES6 Classes - 8- Inheritance

class Shape {
    constructor(color) {
        this.color = color;
    }

     move() {
        console.log('move');
     }
}

// 使用extends之后不用重设constructor
class Circle extends Shape {
    constructor(color, radius) {
        // 如果父类中由一个构造器,则子类的构造器必须先调用父类的构造器,以创建一个父类实例
        super(color);
        this.radius = radius;
    }

    draw() {
        console.log('draw');
    }
}

const c = new Circle('red', 1);
console.log(c);

ES6 Classes - 9- Method Overriding

class Shape {
     move() {
        console.log('move');
     }
}

// 使用extends之后不用重设constructor
class Circle extends Shape {
    move() {
        super.move();
        console.log('Circle move')
    }
}

const c = new Circle();
c.move();

ES6 Classes - 11- Exercise

const _items = new WeakMap();

class Stack {
    constructor() {
        _items.set(this, []);
    }

    get count() {
        return _items.get(this).length;
    }

    peek() {
        if (_items.get(this).length === 0)
            throw new Error('Empty');

        return _items.get(this)[_items.get(this).length];
    }

    pop() {
        if (_items.get(this).length === 0)
            throw new Error('Empty');

        return _items.get(this).pop();
    }

    push(obj) {
       _items.get(this).push(obj); 
    }

}

const s = new Stack();

ES6 Tooling - 1- Modules

在这里插入图片描述

ES6 Tooling - 2- CommonJS Modules

  • 高度关联的东西应该放在一起
// Implementation Detail
const _radius = new WeakMap();

// Public Interface
class Circle {
    constructor(radius) {
        _radius.set(this, radius);
    }

    draw() {
        console.log('Circle with radius' + _radius.get(this));
    }
}

module.exports = Circle;
// require调用的模块和exports公开的对象是一样的
const Circle = require('./circle ');

const c = new Circle(10);
c.draw();

ES6 Tooling - 3- ES6 Modules

// index
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Hello World</h1>
    <script type = "module" src="index.js"></script>
</body>
</html> 
// circle.js

// Implementation Detail
const _radius = new WeakMap();

// Public Interface
export class Circle {
    constructor(radius) {
        _radius.set(this, radius);
    }

    draw() {
        console.log('Circle with radius' + _radius.get(this));
    }
}
// index.js
import { Circle } from "./circle.js"; 

const c = new Circle(10);
c.draw();

ES6 Tooling - 4- ES6 Tooling

在这里插入图片描述

ES6 Tooling - 5- Babel

  • node里的npm功能
npm init --yes
npm i babel -cli@6.26.0 babel -core@6.26.0 babel-preset-env@1.6.1 --save 

修改package.json
在这里插入图片描述

npm run babel

ES6 Tooling - 6- Webpack

sudo npm i -g webpack -cli@2.0.14
webpack-cli init

在这里插入图片描述

npm init --yes

在这里插入图片描述

npm run build

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/134798.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

jrtt 某头条网页版 _signature参数逆向

本文仅供参考学习&#xff0c;如有侵权可联系本人 目标网站 aHR0cHM6Ly93d3cudG91dGlhby5jb20vYy91c2VyL3Rva2VuL01TNHdMakFCQUFBQWE0alpUdzhvRlZnaUJIREprMTA1NDdBVFBUb050aHlsVDRqWndZMmlrMXcvPw接口分析 token&#xff1a;需要采集用户 _signature&#xff1a;加密参数 ai…

【每日一leetcode】Day2 链表(简单)

一、剑指 Offer 06. 从尾到头打印链表 输入一个链表的头节点&#xff0c;从尾到头反过来返回每个节点的值&#xff08;用数组返回&#xff09;。 示例 1&#xff1a; 输入&#xff1a;head [1,3,2] 输出&#xff1a;[2,3,1] 限制&#xff1a; 0 < 链表长度 < 10000…

SCI论文解读复现【NO.3】MSFT-YOLO:基于变压器的改进YOLOv5钢表面缺陷检测(代码已复现)

此前出了目标检测算法改进专栏&#xff0c;但是对于应用于什么场景&#xff0c;需要什么改进方法对应与自己的应用场景有效果&#xff0c;并且多少改进点能发什么水平的文章&#xff0c;为解决大家的困惑&#xff0c;此系列文章旨在给大家解读发表高水平学术期刊中的SCI论文&am…

HCIP第三天ospf星型和全连实验

HCIP文章目录 文章目录HCIP文章目录ospf实验实验要求拓扑图R1/4/5为全连的MGRE结构所有私有网段可以互相通讯ospf实验 实验要求 1、R6为ISP只能配置ip地址&#xff0c;R1-5的环回为私有网段 2、R1/4/5为全连的MGRE结构&#xff0c;R1/2/3为星型的拓扑结构&#xff0c;R1为中心…

stm32平衡小车(1)---蓝牙模块及其bug处理

基于stm32c8t6开发板 一&#xff0c;蓝牙模块HC-05 1.外观 2.接线方式 TX----->PB10 RX----->PB11 VCC----->3.3V GND---->GND 3.AT模式 不用烧录代码&#xff0c;直接将c8t6和HC-05相连接&#xff0c;通过XCOM或者SSCOM软件便可以进入调试模式&a…

MySQL常见深入优化

一、分页查询优化 1. SQL语句准备 CREATE TABLE employees (id INT ( 11 ) NOT NULL AUTO_INCREMENT,name VARCHAR ( 24 ) NOT NULL DEFAULT COMMENT 姓名,age INT ( 11 ) NOT NULL DEFAULT 0 COMMENT 年龄,position VARCHAR ( 20 ) NOT NULL DEFAULT COMMENT 职位,hire_ti…

(Django+redis双机配置)ubuntu虚拟机配置redis,window中django访问

目录 Ubuntu虚拟机配置redis 进入root用户 配置redis服务 开启端口 1.设置密码 2.关闭只允许本机访问 3.关闭保护模式 双向ping测试 ubuntu开启SSH服务 Django中 Django中settings配置redis Ubuntu虚拟机配置redis 进入root用户 首先要进入root用户 后续一定保证要…

Spring Boot内存泄露,排查

背景 为了更好地实现对项目的管理&#xff0c;我们将组内一个项目迁移到MDP框架&#xff08;基于Spring Boot&#xff09;&#xff0c;随后我们就发现系统会频繁报出Swap区域使用量过高的异常。笔者被叫去帮忙查看原因&#xff0c;发现配置了4G堆内内存&#xff0c;但是实际使…

利用kafka发送系统

kafka是一种消息队列框架。 如果不用消息队列框架&#xff0c;就需要用阻塞队列来实现发送系统消息和系统通知 1.阻塞队列 阻塞队列是一种用来解决进程间通信的方式 阻塞队列依靠自带的两个方法put(往队列里面存数据)和take(从队列里面取数据) 2.Kafka kafka最早只是用来发…

CV | 计算机视觉中数据集的txt,csv数据预处理代码及实例

本文使用同一个数据集进行数据预处理练习&#xff0c;其中包含了人脸图片文件夹&#xff0c;CSV文件&#xff0c;txt文件。 数据集主要是针对于人脸照片进行年龄以及性别的预测&#xff0c;在导入模型签的一些简单的数据处理。 1.对人脸图片文件夹&#xff0c;txt文件的操作 …

详解 Redis 中的 RDB 快照

内存快照。所谓内存快照&#xff0c;就是指内存中的数据在某一个时刻的状态记录。这就类似于照片&#xff0c;当你给朋友拍照时&#xff0c;一张照片就能把朋友一瞬间的形象完全记下来。 对 Redis 来说&#xff0c;它实现类似照片记录效果的方式&#xff0c;就是把某一时刻的状…

1D/2D动画混合

1、动画混合 游戏动画中常见的功能就是在两个或者多个相似运动之间进行混合&#xff0c;比如&#xff1a; 根据角色的速度来混合行走和奔跑动画根据角色的转向来混合向左或向右倾斜的动作 可以理解是高级版的动画过渡&#xff0c;之前的动画过渡是处理两个不同类型动作之间切…

【ROS】—— ROS通信机制——参数服务器(四)

文章目录前言1. 参数服务器理论模型2. 参数操作(C)2.1 增加参数2.2 参数修改2.3 参数的获取2.3.1 ros::NodeHandle2.3.2 ros::param2.4 参数的删除3. 参数操作(python)3.1 增加参数与修改参数3.2 获取参数3.3 删除参数前言 &#x1f4e2;本系列将依托赵虚左老师的ROS课程&#…

九联UNT403G/UNT413G_国科GK6323芯片_5621ds无线wifi_免拆卡刷固件

九联UNT403G&#xff0f;UNT413G_国科GK6323芯片_5621ds无线wifi_免拆卡刷固件。 固件特点&#xff1a; 1、修改dns&#xff0c;三网通用&#xff1b; 2、开放原厂固件屏蔽的市场安装和u盘安装apk&#xff1b; 3、无开机广告&#xff0c;无系统更新&#xff0c;不在被强制升…

判断成绩-C语言实现

任务描述 本关任务&#xff1a;判定学生成绩。 相关知识 if-else 分支语句基本用法 C 语言提供了 if-else 分支语句用于实现程序的选择结构。 基本格式如下&#xff1a; if ( 表达式 ) 语句A else 语句B 基本流程图如下&#xff1a; 图1 if-else 分支语句流程图 从上面的…

单相全桥逆变原理及仿真实验

前言 一、单相全桥逆变器组成原理 1.全桥逆变电路拓扑结构 2.单相逆变器的SPWM调制方式 二、单相全桥逆变器仿真 1.SPWM调制波仿真 2.全桥逆变仿真 三、SPWM单片机程序实现 1.CubeMX配置 2.SPWM正弦表数据生成 3.Keil5代码 4.protues仿真观测波形 前言 通常把直流电变成…

力扣 # 1323. 6 和 9 组成的最大数字 JAVA实现

力扣 1323. 6 和 9 组成的最大数字 给你一个仅由数字 6 和 9 组成的正整数 num。 你最多只能翻转一位数字&#xff0c;将 6 变成 9&#xff0c;或者把 9 变成 6 。 请返回你可以得到的最大数字。 难度&#xff1a;简单 示例 1&#xff1a; 输入&#xff1a;num 9669 输出&a…

基于采样的规划算法之动态规划方法

经过前面对RRT的介绍,我们发现基于采样的规划算法与基于图搜索的规划算法都是通过对路径树进行拓展新节点,来找到起点到终点的路径解。RRT家族通过随机采样来生成这棵路径树,随机采样会面临采样低效的问题——大部分采样的新节点都无益于提升路径解的最优性。动态规划基于特…

JS对数组的操作详解

目录 shift 方法 unshift 方法 reverse方法 sort方法 reduce方法 concat方法 join方法 push方法 pop方法 slice方法 splice方法 forEach方法 map方法 filter方法 every方法 some方法 indexOf方法 find方法 includes方法 在这里总结一下JS的数组方法&#xf…

JDBC基本使用

文章目录一、JDBC技术1.1、JDBC概念1.2、JDBC作用1.3、JDBC工作原理1.4、JDBC工作流程二、使用JDBC访问数据库2.1、创建Maven项目2.2、添加数据库依赖2.2.1、mysql依赖2.2.2、oracle依赖2.3、编写代码2.3.1、加载驱动2.3.2、通过DriverManager获取connection连接2.3.3、执行SQL…