Skip to content

Commit

Permalink
Merge branch 'iluwatar:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgodoy authored Nov 10, 2024
2 parents 9cc98d2 + 25bb77e commit 6696afc
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 38 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -3240,6 +3240,15 @@
"contributions": [
"code"
]
},
{
"login": "jeffmorrison",
"name": "jeffmorrison",
"avatar_url": "https://avatars.githubusercontent.com/u/26047158?v=4",
"profile": "https://github.com/jeffmorrison",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 6,
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-355-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-356-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

<br/>
Expand Down Expand Up @@ -534,6 +534,7 @@ This project is licensed under the terms of the MIT license.
</tr>
<tr>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/jasonjyu"><img src="https://avatars.githubusercontent.com/u/10333076?v=4?s=100" width="100px;" alt="jasonjyu"/><br /><sub><b>jasonjyu</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=jasonjyu" title="Code">💻</a></td>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/jeffmorrison"><img src="https://avatars.githubusercontent.com/u/26047158?v=4?s=100" width="100px;" alt="jeffmorrison"/><br /><sub><b>jeffmorrison</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=jeffmorrison" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
71 changes: 36 additions & 35 deletions bytecode/src/main/java/com/iluwatar/bytecode/VirtualMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,59 +67,60 @@ public void execute(int[] bytecode) {
for (var i = 0; i < bytecode.length; i++) {
Instruction instruction = Instruction.getInstruction(bytecode[i]);
switch (instruction) {
case LITERAL:
// Read the next byte from the bytecode.
case LITERAL -> { // Read the next byte from the bytecode.
int value = bytecode[++i];
// Push the next value to stack
stack.push(value);
break;
case SET_AGILITY:
}
case SET_AGILITY -> {
var amount = stack.pop();
var wizard = stack.pop();
setAgility(wizard, amount);
break;
case SET_WISDOM:
amount = stack.pop();
wizard = stack.pop();
}
case SET_WISDOM -> {
var amount = stack.pop();
var wizard = stack.pop();
setWisdom(wizard, amount);
break;
case SET_HEALTH:
amount = stack.pop();
wizard = stack.pop();
}
case SET_HEALTH -> {
var amount = stack.pop();
var wizard = stack.pop();
setHealth(wizard, amount);
break;
case GET_HEALTH:
wizard = stack.pop();
}
case GET_HEALTH -> {
var wizard = stack.pop();
stack.push(getHealth(wizard));
break;
case GET_AGILITY:
wizard = stack.pop();
}
case GET_AGILITY -> {
var wizard = stack.pop();
stack.push(getAgility(wizard));
break;
case GET_WISDOM:
wizard = stack.pop();
}
case GET_WISDOM -> {
var wizard = stack.pop();
stack.push(getWisdom(wizard));
break;
case ADD:
}
case ADD -> {
var a = stack.pop();
var b = stack.pop();
stack.push(a + b);
break;
case DIVIDE:
a = stack.pop();
b = stack.pop();
}
case DIVIDE -> {
var a = stack.pop();
var b = stack.pop();
stack.push(b / a);
break;
case PLAY_SOUND:
wizard = stack.pop();
}
case PLAY_SOUND -> {
var wizard = stack.pop();
getWizards()[wizard].playSound();
break;
case SPAWN_PARTICLES:
wizard = stack.pop();

}
case SPAWN_PARTICLES -> {
var wizard = stack.pop();
getWizards()[wizard].spawnParticles();
break;
default:
}
default -> {
throw new IllegalArgumentException("Invalid instruction value");
}
}
LOGGER.info("Executed " + instruction.name() + ", Stack contains " + getStack());
}
Expand Down
2 changes: 1 addition & 1 deletion hexagonal-architecture/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>4.17.0</version>
<version>4.18.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<guice.version>6.0.0</guice.version>
<system-lambda.version>1.1.0</system-lambda.version>
<maven-surefire-plugin.version>3.5.1</maven-surefire-plugin.version>
<maven-checkstyle-plugin.version>3.5.0</maven-checkstyle-plugin.version>
<maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
<license-maven-plugin.version>4.6</license-maven-plugin.version>
<urm-maven-plugin.version>2.1.1</urm-maven-plugin.version>
<slf4j.version>2.0.16</slf4j.version>
Expand Down

0 comments on commit 6696afc

Please sign in to comment.