Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
iluwatar authored Jan 6, 2025
2 parents 280d90e + c06bd2c commit 471ee47
Showing 139 changed files with 9,440 additions and 145 deletions.
108 changes: 108 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -3240,6 +3240,114 @@
"contributions": [
"code"
]
},
{
"login": "jeffmorrison",
"name": "jeffmorrison",
"avatar_url": "https://avatars.githubusercontent.com/u/26047158?v=4",
"profile": "https://github.com/jeffmorrison",
"contributions": [
"code"
]
},
{
"login": "dmgodoy",
"name": "David M.",
"avatar_url": "https://avatars.githubusercontent.com/u/10840681?v=4",
"profile": "https://github.com/dmgodoy",
"contributions": [
"code"
]
},
{
"login": "apophizzz",
"name": "Patrick Kleindienst",
"avatar_url": "https://avatars.githubusercontent.com/u/12052783?v=4",
"profile": "https://github.com/apophizzz",
"contributions": [
"code"
]
},
{
"login": "proceane",
"name": "Juyeon",
"avatar_url": "https://avatars.githubusercontent.com/u/62143949?v=4",
"profile": "https://github.com/proceane",
"contributions": [
"translation"
]
},
{
"login": "mammadyahyayev",
"name": "Mammad Yahyayev",
"avatar_url": "https://avatars.githubusercontent.com/u/66476643?v=4",
"profile": "https://mammadyahya.vercel.app",
"contributions": [
"doc"
]
},
{
"login": "SalmaAzeem",
"name": "Salma",
"avatar_url": "https://avatars.githubusercontent.com/u/121863224?v=4",
"profile": "https://github.com/SalmaAzeem",
"contributions": [
"code"
]
},
{
"login": "CodeMaverick-143",
"name": "Arpit Sarang",
"avatar_url": "https://avatars.githubusercontent.com/u/182847716?v=4",
"profile": "https://codemaverick-143.github.io/My-Portfolio/",
"contributions": [
"code"
]
},
{
"login": "mayatarek",
"name": "Maya",
"avatar_url": "https://avatars.githubusercontent.com/u/111644421?v=4",
"profile": "https://github.com/mayatarek",
"contributions": [
"translation"
]
},
{
"login": "HabibaMekay",
"name": "HabibaMekay",
"avatar_url": "https://avatars.githubusercontent.com/u/133516736?v=4",
"profile": "https://github.com/HabibaMekay",
"contributions": [
"code"
]
},
{
"login": "Ahmed-Taha-981",
"name": "Ahmed-Taha-981",
"avatar_url": "https://avatars.githubusercontent.com/u/122402269?v=4",
"profile": "https://github.com/Ahmed-Taha-981",
"contributions": [
"code"
]
},
{
"login": "malak-elbanna",
"name": "Malak Elbanna",
"avatar_url": "https://avatars.githubusercontent.com/u/67643605?v=4",
"profile": "https://malakelbanna.netlify.app/",
"contributions": [
"code"
]
},
{
"login": "depthlending",
"name": "BiKangNing",
"avatar_url": "https://avatars.githubusercontent.com/u/164312726?v=4",
"profile": "https://github.com/depthlending",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 6,
61 changes: 0 additions & 61 deletions .github/stale.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Comment on stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity.'
stale-pr-message: 'This PR is stale because it has been open 60 days with no activity.'
close-issue-message: 'This issue was closed because it has been stalled for too long with no activity.'
close-pr-message: 'This PR was closed because it has been stalled for too long with no activity.'
days-before-issue-stale: 60
days-before-pr-stale: 60
days-before-issue-close: -1
days-before-pr-close: -1
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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-367-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

<br/>
@@ -534,6 +534,22 @@ 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>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/dmgodoy"><img src="https://avatars.githubusercontent.com/u/10840681?v=4?s=100" width="100px;" alt="David M."/><br /><sub><b>David M.</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=dmgodoy" title="Code">💻</a></td>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/apophizzz"><img src="https://avatars.githubusercontent.com/u/12052783?v=4?s=100" width="100px;" alt="Patrick Kleindienst"/><br /><sub><b>Patrick Kleindienst</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=apophizzz" title="Code">💻</a></td>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/proceane"><img src="https://avatars.githubusercontent.com/u/62143949?v=4?s=100" width="100px;" alt="Juyeon"/><br /><sub><b>Juyeon</b></sub></a><br /><a href="#translation-proceane" title="Translation">🌍</a></td>
<td align="center" valign="top" width="16.66%"><a href="https://mammadyahya.vercel.app"><img src="https://avatars.githubusercontent.com/u/66476643?v=4?s=100" width="100px;" alt="Mammad Yahyayev"/><br /><sub><b>Mammad Yahyayev</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mammadyahyayev" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/SalmaAzeem"><img src="https://avatars.githubusercontent.com/u/121863224?v=4?s=100" width="100px;" alt="Salma"/><br /><sub><b>Salma</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=SalmaAzeem" title="Code">💻</a></td>
<td align="center" valign="top" width="16.66%"><a href="https://codemaverick-143.github.io/My-Portfolio/"><img src="https://avatars.githubusercontent.com/u/182847716?v=4?s=100" width="100px;" alt="Arpit Sarang"/><br /><sub><b>Arpit Sarang</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=CodeMaverick-143" title="Code">💻</a></td>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/mayatarek"><img src="https://avatars.githubusercontent.com/u/111644421?v=4?s=100" width="100px;" alt="Maya"/><br /><sub><b>Maya</b></sub></a><br /><a href="#translation-mayatarek" title="Translation">🌍</a></td>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/HabibaMekay"><img src="https://avatars.githubusercontent.com/u/133516736?v=4?s=100" width="100px;" alt="HabibaMekay"/><br /><sub><b>HabibaMekay</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=HabibaMekay" title="Code">💻</a></td>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/Ahmed-Taha-981"><img src="https://avatars.githubusercontent.com/u/122402269?v=4?s=100" width="100px;" alt="Ahmed-Taha-981"/><br /><sub><b>Ahmed-Taha-981</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Ahmed-Taha-981" title="Code">💻</a></td>
<td align="center" valign="top" width="16.66%"><a href="https://malakelbanna.netlify.app/"><img src="https://avatars.githubusercontent.com/u/67643605?v=4?s=100" width="100px;" alt="Malak Elbanna"/><br /><sub><b>Malak Elbanna</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=malak-elbanna" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="16.66%"><a href="https://github.com/depthlending"><img src="https://avatars.githubusercontent.com/u/164312726?v=4?s=100" width="100px;" alt="BiKangNing"/><br /><sub><b>BiKangNing</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=depthlending" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
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
@@ -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());
}
60 changes: 46 additions & 14 deletions composite-view/web/index.jsp
Original file line number Diff line number Diff line change
@@ -26,21 +26,53 @@
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<head>
<title>Composite Patterns Mock News Site</title>
<style>
h1 { text-align: center;}
h2 { text-align: center;}
h3 { text-align: center;}
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
h1, h2, h3 {
text-align: center;
color: #333;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 2em;
margin-top: 20px;
}
h3 {
font-size: 1.5em;
margin-top: 10px;
}
.parameters {
max-width: 600px;
margin: 0 auto;
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
</head>
<body>
<h1>Welcome To The Composite Patterns Mock News Site</h1>
<h2>Send a GET request to the "/news" path to see the composite view with mock news</h2>
<h2>Use the following parameters:</h2>
<h3>name: string name to be dynamically displayed</h3>
<h3>bus: boolean for whether you want to see the mock business news</h3>
<h3>world: boolean for whether you want to see the mock world news</h3>
<h3>sci: boolean for whether you want to see the mock world news</h3>
<h3>sport: boolean for whether you want to see the mock world news</h3>
</body>
<div class="parameters">
<h2>Send a GET request to the "/news" path to see the composite view with mock news</h2>
<h2>Use the following parameters:</h2>
<h3>name: <em>string</em> - Your name to be dynamically displayed</h3>
<h3>bus: <em>boolean</em> - Set to true to see mock business news</h3>
<h3>world: <em>boolean</em> - Set to true to see mock world news</h3>
<h3>sci: <em>boolean</em> - Set to true to see mock science news</h3>
<h3>sport: <em>boolean</em> - Set to true to see mock sports news</h3>
<h2>Example Request:</h2>
<h3>/news?name=John&bus=true&world=false&sci=true&sport=false</h3>
<h3>If the request fails, ensure you have the correct parameters and try again.</h3>
</div>
</body>
</html>
Loading

0 comments on commit 471ee47

Please sign in to comment.