Skip to content

Commit c61a367

Browse files
committed
Calculator: Easte egg in division by zero message. Propossed by @ghostslayer989 in ShizukuIchi#54
1 parent 41d0bd9 commit c61a367

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/WinXP/apps/Calculator/index.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ export default function Calculator({ onClose }) {
1212
const [auxValue, setAuxValue] = useState(emptyValue);
1313
const [currentOperation, setCurrentOperation] = useState(null);
1414
const [operationClicked, setOperationClicked] = useState(false);
15+
const [divisionByZeroCounter, setDivisionByZeroCounter] = useState(0);
16+
const divisionByZeroMessages = [
17+
'Cannot divide by zero',
18+
'I still cannot divide by zero',
19+
'Repeteadly trying won\'t change this!',
20+
'Stop already! You\'re scaring the ALU.',
21+
'Alright, do whatever you want.'
22+
];
1523

1624
function hoverOption(option) {
1725
if (openOption) setOpenOption(option);
@@ -72,7 +80,12 @@ export default function Calculator({ onClose }) {
7280
case '/':
7381
if (b === 0) {
7482
// Division by zero
75-
setCurrentValue('Cannot divide by zero.');
83+
if (divisionByZeroCounter < divisionByZeroMessages.length) {
84+
setCurrentValue(divisionByZeroMessages[divisionByZeroCounter]);
85+
setDivisionByZeroCounter(divisionByZeroCounter + 1);
86+
break;
87+
}
88+
setCurrentValue(divisionByZeroMessages[0]);
7689
break;
7790
}
7891
setCurrentValue(a / b);

0 commit comments

Comments
 (0)