当前位置:网站首页>The space between the left and right of the movie ticket seats is empty and cannot be selected
The space between the left and right of the movie ticket seats is empty and cannot be selected
2022-04-23 02:53:00 【Diga】
1. Check whether each seat will leave a vacant seat
checkSeat(element) {
// The standard for the 1. Both the left and right sides must be retained Two compartment seat + Maximum extended seat ( That is, the selected seat minus itself )
// 2. All seats against the wall and sold seats pass directly through
// Check left and right 2 A seat
const checkNum = 2; // 2 + this.selectedSeatList.length -1
const gRowBasic = element.gRow;
const gColBasic = element.gCol;
let otherLoveSeatIndex = element.otherLoveSeatIndex;
if (otherLoveSeatIndex != null) {
// If it's a couple seat Don't test
return true;
}
// Check the left side of the seat
let left = this.checkSeatDirection(gRowBasic, gColBasic, checkNum, '-');
console.info(left, 'left');
// If the left side has been checked out, it is against the aisle directly return true
if (left === 'special') {
return true;
}
// Check the right side of the seat
let right = this.checkSeatDirection(gRowBasic, gColBasic, checkNum, '+');
console.info(right, 'right');
if (right === 'special') {
// Whether or not the left side is in any state Check that the right side is directly against the aisle return true
return true;
} else if (right === 'normal' && left === 'normal') {
// If there are rich seats on both sides return true
return true;
} else if (right === 'fail' && left === 'fail') {
// If both left and right sides fail the test return false
return false;
}
return true;
},
2. Check that the left and right seats meet the rules
checkSeatDirection(gRowBasic, gColBasic, checkNum, direction) {
// Number of vacancies
let emptySeat = 0;
let x = 1; // Check location Only in x There is an aisle in the position of , sold , maintenance
for (let i = 1; i <= checkNum; i++) {
let iter; // according to gRow gCol direction Find the order on the left side of the inspection seat checkNum
if (direction === '-') {
iter = this.seatList.find((el) => el.gRow === gRowBasic && el.gCol === gColBasic - i);
} else if (direction === '+') {
iter = this.seatList.find((el) => el.gRow === gRowBasic && el.gCol === gColBasic + i);
}
if (x === i) {
if (iter === undefined) {
// aisle
return 'special';
}
if (iter.nowIcon === iter.soldedIcon || iter.nowIcon === iter.fixIcon) {
// Sold or repaired
return 'special';
}
if (iter.nowIcon === iter.selectedIcon) {
// Selected Postpone one
x++;
continue;
}
} else {
if (iter === undefined) {
// aisle
return 'fail';
}
if (iter.nowIcon === iter.soldedIcon || iter.nowIcon === iter.fixIcon || iter.nowIcon === iter.selectedIcon) {
// Sold or repaired
return 'fail';
}
}
emptySeat++;
if (emptySeat >= 2) {
return 'normal';
}
}
},
版权声明
本文为[Diga]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220717433481.html
边栏推荐
- 谷雨
- Devil cold rice 𞓜 078 devil answers the market in Shanghai and Nanjing; Communication and guidance; Winning the country and killing and screening; The purpose of making money; Change other people's op
- Fashion MNIST 数据集分类训练
- 学习正则表达式选项、断言
- Chapter VI project information management system summary
- JZ22 链表中倒数最后k个结点
- ROP Emporium x86_64 7~8题
- The problem of removing spaces from strings
- Learn regular expression options, assertions
- 基于多态的职工管理系统源码与一些理解
猜你喜欢
php+mysql对下拉框搜索的内容修改
Store consumption SMS notification template
The way to conquer C language
grain rain
Log cutting - build a remote log collection server
ROP Emporium x86_ 64 7 ~ 8 questions
Processes and threads
Encapsulation of ele table
C language 171 Number of recent palindromes
L2-006 树的遍历(中后序确定二叉树&层序遍历)
随机推荐
Android high-level interview must ask: overall business and project architecture design and reconstruction
AC380V drop 5v12v24v200ma, UHV non isolated chip IC scheme
ele之Table表格的封装
Shell learning notes -- shell processing of output stream awk
ROP Emporium x86_64 7~8题
windows MySQL8 zip安装
grain rain
Chapter VI project information management system summary
Day 4 of learning rhcsa
机器学习(周志华) 第十四章概率图模型
The interface request takes too long. Jstack observes the lock holding
Codeforces Round #784 (Div. 4) (A - H)题解
Linux redis - redis database caching service
VirtualBox virtual machine (Oracle VM)
Redis data server / database / cache (2022)
Restart redis
Shell script learning -- practical case
Liunx foundation - zabbix5 0 monitoring system installation and deployment
《信息系统项目管理师总结》第六章 项目人力资源管理
解决win7 中powershell挖矿占用CPU100%