반응형
넥사크로(Nexacro)로 구현된 로또 번호 생성기 프로그램의 예시 소스 코드
다음은 넥사크로에서 사용할 수 있는 JavaScript와 XML로 작성된 소스 코드입니다.
index.xadl 파일:
xmlCopy code
<?xml version="1.0" encoding="UTF-8"?>
<Frame xmlns="http://www.nexacroplatform.com/platform/description/ds" xmlns:core="java.lang" format="true"> <Variables>
<Variable id="numRange" type="Number" value="45"/>
<Variable id="numCount" type="Number" value="6"/>
<Variable id="lottoNumbers" type="String" value=""/>
</Variables>
<Layout>
<Div id="divMain" left="20" top="20" width="300" height="200">
<StaticText id="staticTextTitle" text="로또 번호 생성기" left="20" top="20" width="200" height="30"/>
<StaticText id="staticTextRange" text="숫자 범위 (1 ~ 45)" left="20" top="60" width="200" height="20"/>
<Edit id="editRange" value="#numRange#" left="20" top="80" width="100" height="20"/>
<StaticText id="staticTextCount" text="생성할 숫자 개수" left="20" top="110" width="200" height="20"/>
<Edit id="editCount" value="#numCount#" left="20" top="130" width="100" height="20"/>
<Button id="buttonGenerate" text="번호 생성" left="20" top="160" width="100" height="30" onclick="buttonGenerate_onclick"/>
<StaticText id="staticTextResult" text="생성된 번호" left="150" top="60" width="200" height="20"/>
<TextArea id="textAreaResult" value="#lottoNumbers#" left="150" top="80" width="120" height="100"/>
</Div>
</Layout>
<Script>
<![CDATA[
function buttonGenerate_onclick(obj) {
var range = parseInt(this.divMain.editRange.value);
var count = parseInt(this.divMain.editCount.value);
var numbers = [];
while (numbers.length < count) {
var randomNum = Math.floor(Math.random() * range) + 1;
if (numbers.indexOf(randomNum) === -1) {
numbers.push(randomNum);
}
}
this.divMain.lottoNumbers = numbers.join(", ");
}
]]>
</Script>
</Frame>
위의 코드는 넥사크로 프레임워크를 사용하여 구현된 로또 번호 생성기 프로그램의 예시입니다. 사용자가 숫자 범위와 생성할 숫자 개수를 입력하고 "번호 생성" 버튼을 클릭하면, 지정된 범위 내에서 임의의 로또 번호를 생성하고 출력 영역에 표시합니다.
위의 코드를 넥사크로 스튜디오에 붙여넣고 실행하면 로또 번호 생성기 프로그램을 확인할 수 있습니다
'[프로그램]' 카테고리의 다른 글
| C# 윈도우 화면비율 자동채움 프레임워크 코드 무료소스 오픈소스 (0) | 2023.06.26 |
|---|---|
| C# 10개의 모양으로 구동하는 버튼 소스 (0) | 2023.06.26 |
| C#에서 이더넷, RS-485 및 RS-232 통신을 구현하는 예제 코드 (0) | 2023.06.26 |
| C#으로 2중 라인 엘리베이터 (0) | 2023.06.26 |
| C#으로 자동 로또 번호 생성 프로그램. (0) | 2023.06.26 |