Skip to content

Commit 471ee47

Browse files
authored
Merge branch 'master' into master
2 parents 280d90e + c06bd2c commit 471ee47

File tree

139 files changed

+9440
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+9440
-145
lines changed

.all-contributorsrc

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,114 @@
32403240
"contributions": [
32413241
"code"
32423242
]
3243+
},
3244+
{
3245+
"login": "jeffmorrison",
3246+
"name": "jeffmorrison",
3247+
"avatar_url": "https://avatars.githubusercontent.com/u/26047158?v=4",
3248+
"profile": "https://github.com/jeffmorrison",
3249+
"contributions": [
3250+
"code"
3251+
]
3252+
},
3253+
{
3254+
"login": "dmgodoy",
3255+
"name": "David M.",
3256+
"avatar_url": "https://avatars.githubusercontent.com/u/10840681?v=4",
3257+
"profile": "https://github.com/dmgodoy",
3258+
"contributions": [
3259+
"code"
3260+
]
3261+
},
3262+
{
3263+
"login": "apophizzz",
3264+
"name": "Patrick Kleindienst",
3265+
"avatar_url": "https://avatars.githubusercontent.com/u/12052783?v=4",
3266+
"profile": "https://github.com/apophizzz",
3267+
"contributions": [
3268+
"code"
3269+
]
3270+
},
3271+
{
3272+
"login": "proceane",
3273+
"name": "Juyeon",
3274+
"avatar_url": "https://avatars.githubusercontent.com/u/62143949?v=4",
3275+
"profile": "https://github.com/proceane",
3276+
"contributions": [
3277+
"translation"
3278+
]
3279+
},
3280+
{
3281+
"login": "mammadyahyayev",
3282+
"name": "Mammad Yahyayev",
3283+
"avatar_url": "https://avatars.githubusercontent.com/u/66476643?v=4",
3284+
"profile": "https://mammadyahya.vercel.app",
3285+
"contributions": [
3286+
"doc"
3287+
]
3288+
},
3289+
{
3290+
"login": "SalmaAzeem",
3291+
"name": "Salma",
3292+
"avatar_url": "https://avatars.githubusercontent.com/u/121863224?v=4",
3293+
"profile": "https://github.com/SalmaAzeem",
3294+
"contributions": [
3295+
"code"
3296+
]
3297+
},
3298+
{
3299+
"login": "CodeMaverick-143",
3300+
"name": "Arpit Sarang",
3301+
"avatar_url": "https://avatars.githubusercontent.com/u/182847716?v=4",
3302+
"profile": "https://codemaverick-143.github.io/My-Portfolio/",
3303+
"contributions": [
3304+
"code"
3305+
]
3306+
},
3307+
{
3308+
"login": "mayatarek",
3309+
"name": "Maya",
3310+
"avatar_url": "https://avatars.githubusercontent.com/u/111644421?v=4",
3311+
"profile": "https://github.com/mayatarek",
3312+
"contributions": [
3313+
"translation"
3314+
]
3315+
},
3316+
{
3317+
"login": "HabibaMekay",
3318+
"name": "HabibaMekay",
3319+
"avatar_url": "https://avatars.githubusercontent.com/u/133516736?v=4",
3320+
"profile": "https://github.com/HabibaMekay",
3321+
"contributions": [
3322+
"code"
3323+
]
3324+
},
3325+
{
3326+
"login": "Ahmed-Taha-981",
3327+
"name": "Ahmed-Taha-981",
3328+
"avatar_url": "https://avatars.githubusercontent.com/u/122402269?v=4",
3329+
"profile": "https://github.com/Ahmed-Taha-981",
3330+
"contributions": [
3331+
"code"
3332+
]
3333+
},
3334+
{
3335+
"login": "malak-elbanna",
3336+
"name": "Malak Elbanna",
3337+
"avatar_url": "https://avatars.githubusercontent.com/u/67643605?v=4",
3338+
"profile": "https://malakelbanna.netlify.app/",
3339+
"contributions": [
3340+
"code"
3341+
]
3342+
},
3343+
{
3344+
"login": "depthlending",
3345+
"name": "BiKangNing",
3346+
"avatar_url": "https://avatars.githubusercontent.com/u/164312726?v=4",
3347+
"profile": "https://github.com/depthlending",
3348+
"contributions": [
3349+
"doc"
3350+
]
32433351
}
32443352
],
32453353
"contributorsPerLine": 6,

.github/stale.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/stale.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Comment on stale issues and PRs'
2+
on:
3+
schedule:
4+
- cron: '30 1 * * *'
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v9
11+
with:
12+
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity.'
13+
stale-pr-message: 'This PR is stale because it has been open 60 days with no activity.'
14+
close-issue-message: 'This issue was closed because it has been stalled for too long with no activity.'
15+
close-pr-message: 'This PR was closed because it has been stalled for too long with no activity.'
16+
days-before-issue-stale: 60
17+
days-before-pr-stale: 60
18+
days-before-issue-close: -1
19+
days-before-pr-close: -1

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
77
[![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)
88
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
9-
[![All Contributors](https://img.shields.io/badge/all_contributors-355-orange.svg?style=flat-square)](#contributors-)
9+
[![All Contributors](https://img.shields.io/badge/all_contributors-367-orange.svg?style=flat-square)](#contributors-)
1010
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1111

1212
<br/>
@@ -534,6 +534,22 @@ This project is licensed under the terms of the MIT license.
534534
</tr>
535535
<tr>
536536
<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>
537+
<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>
538+
<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>
539+
<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>
540+
<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>
541+
<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>
542+
</tr>
543+
<tr>
544+
<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>
545+
<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>
546+
<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>
547+
<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>
548+
<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>
549+
<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>
550+
</tr>
551+
<tr>
552+
<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>
537553
</tr>
538554
</tbody>
539555
</table>

bytecode/src/main/java/com/iluwatar/bytecode/VirtualMachine.java

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -67,59 +67,60 @@ public void execute(int[] bytecode) {
6767
for (var i = 0; i < bytecode.length; i++) {
6868
Instruction instruction = Instruction.getInstruction(bytecode[i]);
6969
switch (instruction) {
70-
case LITERAL:
71-
// Read the next byte from the bytecode.
70+
case LITERAL -> { // Read the next byte from the bytecode.
7271
int value = bytecode[++i];
7372
// Push the next value to stack
7473
stack.push(value);
75-
break;
76-
case SET_AGILITY:
74+
}
75+
case SET_AGILITY -> {
7776
var amount = stack.pop();
7877
var wizard = stack.pop();
7978
setAgility(wizard, amount);
80-
break;
81-
case SET_WISDOM:
82-
amount = stack.pop();
83-
wizard = stack.pop();
79+
}
80+
case SET_WISDOM -> {
81+
var amount = stack.pop();
82+
var wizard = stack.pop();
8483
setWisdom(wizard, amount);
85-
break;
86-
case SET_HEALTH:
87-
amount = stack.pop();
88-
wizard = stack.pop();
84+
}
85+
case SET_HEALTH -> {
86+
var amount = stack.pop();
87+
var wizard = stack.pop();
8988
setHealth(wizard, amount);
90-
break;
91-
case GET_HEALTH:
92-
wizard = stack.pop();
89+
}
90+
case GET_HEALTH -> {
91+
var wizard = stack.pop();
9392
stack.push(getHealth(wizard));
94-
break;
95-
case GET_AGILITY:
96-
wizard = stack.pop();
93+
}
94+
case GET_AGILITY -> {
95+
var wizard = stack.pop();
9796
stack.push(getAgility(wizard));
98-
break;
99-
case GET_WISDOM:
100-
wizard = stack.pop();
97+
}
98+
case GET_WISDOM -> {
99+
var wizard = stack.pop();
101100
stack.push(getWisdom(wizard));
102-
break;
103-
case ADD:
101+
}
102+
case ADD -> {
104103
var a = stack.pop();
105104
var b = stack.pop();
106105
stack.push(a + b);
107-
break;
108-
case DIVIDE:
109-
a = stack.pop();
110-
b = stack.pop();
106+
}
107+
case DIVIDE -> {
108+
var a = stack.pop();
109+
var b = stack.pop();
111110
stack.push(b / a);
112-
break;
113-
case PLAY_SOUND:
114-
wizard = stack.pop();
111+
}
112+
case PLAY_SOUND -> {
113+
var wizard = stack.pop();
115114
getWizards()[wizard].playSound();
116-
break;
117-
case SPAWN_PARTICLES:
118-
wizard = stack.pop();
115+
116+
}
117+
case SPAWN_PARTICLES -> {
118+
var wizard = stack.pop();
119119
getWizards()[wizard].spawnParticles();
120-
break;
121-
default:
120+
}
121+
default -> {
122122
throw new IllegalArgumentException("Invalid instruction value");
123+
}
123124
}
124125
LOGGER.info("Executed " + instruction.name() + ", Stack contains " + getStack());
125126
}

composite-view/web/index.jsp

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,53 @@
2626
--%>
2727
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
2828
<html>
29-
<head>
29+
<head>
30+
<title>Composite Patterns Mock News Site</title>
3031
<style>
31-
h1 { text-align: center;}
32-
h2 { text-align: center;}
33-
h3 { text-align: center;}
32+
body {
33+
font-family: Arial, sans-serif;
34+
background-color: #f4f4f4;
35+
margin: 0;
36+
padding: 20px;
37+
}
38+
h1, h2, h3 {
39+
text-align: center;
40+
color: #333;
41+
}
42+
h1 {
43+
font-size: 2.5em;
44+
}
45+
h2 {
46+
font-size: 2em;
47+
margin-top: 20px;
48+
}
49+
h3 {
50+
font-size: 1.5em;
51+
margin-top: 10px;
52+
}
53+
.parameters {
54+
max-width: 600px;
55+
margin: 0 auto;
56+
background: #fff;
57+
padding: 20px;
58+
border-radius: 8px;
59+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
60+
}
3461
</style>
35-
</head>
36-
<body>
62+
</head>
63+
<body>
3764
<h1>Welcome To The Composite Patterns Mock News Site</h1>
38-
<h2>Send a GET request to the "/news" path to see the composite view with mock news</h2>
39-
<h2>Use the following parameters:</h2>
40-
<h3>name: string name to be dynamically displayed</h3>
41-
<h3>bus: boolean for whether you want to see the mock business news</h3>
42-
<h3>world: boolean for whether you want to see the mock world news</h3>
43-
<h3>sci: boolean for whether you want to see the mock world news</h3>
44-
<h3>sport: boolean for whether you want to see the mock world news</h3>
45-
</body>
65+
<div class="parameters">
66+
<h2>Send a GET request to the "/news" path to see the composite view with mock news</h2>
67+
<h2>Use the following parameters:</h2>
68+
<h3>name: <em>string</em> - Your name to be dynamically displayed</h3>
69+
<h3>bus: <em>boolean</em> - Set to true to see mock business news</h3>
70+
<h3>world: <em>boolean</em> - Set to true to see mock world news</h3>
71+
<h3>sci: <em>boolean</em> - Set to true to see mock science news</h3>
72+
<h3>sport: <em>boolean</em> - Set to true to see mock sports news</h3>
73+
<h2>Example Request:</h2>
74+
<h3>/news?name=John&bus=true&world=false&sci=true&sport=false</h3>
75+
<h3>If the request fails, ensure you have the correct parameters and try again.</h3>
76+
</div>
77+
</body>
4678
</html>

0 commit comments

Comments
 (0)