当前位置:网站首页>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
边栏推荐
- Chapter IV project cost management of information system project manager summary
- Efficient music format conversion tool Music Converter Pro
- VirtualBox virtual machine (Oracle VM)
- Microservices (distributed architecture)
- Day 3 of learning rhcsa
- Encapsulate components such as pull-down menu based on ele
- [learn junit5 from official documents] [II] [writingtests] [learning notes]
- php+mysql對下拉框搜索的內容修改
- JS using the parameters of art template
- Source code and some understanding of employee management system based on polymorphism
猜你喜欢

Flink stream processing engine system learning (II)

接口请求时间太长,jstack观察锁持有情况

Huawei machine test question -- deformation of hj53 Yang Hui triangle

Shell script learning notes - regular expressions

ele之Table表格的封装

Modify the content of MySQL + PHP drop-down box

php+mysql對下拉框搜索的內容修改

解决win7 中powershell挖矿占用CPU100%

How to build an integrated industrial Internet plus hazardous safety production management platform?

Store consumption SMS notification template
随机推荐
Log cutting - build a remote log collection server
《信息系统项目管理师总结》第七章 项目沟通管理
Windows MySQL 8 zip installation
Leangoo brain map - shared multi person collaborative mind mapping tool
Error installing Mongo service 'mongodb server' on win10 failed to start
工业互联网+危化安全生产综合管理平台怎样建
Modification du contenu de la recherche dans la boîte déroulante par PHP + MySQL
谷雨
mysql function函数语法
Android high-level interview must ask: overall business and project architecture design and reconstruction
First day of rhcsa
Rhcsa second day operation
Encapsulation of ele table
eventBus
《信息系統項目管理師總結》第六章 項目人力資源管理
Codeforces Round #784 (Div. 4) (A - H)题解
Shell learning notes -- shell processing of output stream awk
Configuring Apache Web services for servers such as Tianyi cloud
JZ35 复杂链表的复制
Shell script learning -- practical case