Professional Documents
Culture Documents
Полностю курсач
Полностю курсач
КП.ХПТК. 00481 - 25 81 01
зміст
1. Вступ 2
2. Технічні характеристики 3
2.1.Постановка задачі 3
2.2.Визначення структури вхідних даних 3
2.3.Визначення структури вихідних даних 4
2.4.Визначення вимог до технічних засобів 4
2.5.Опис мови програмування 4
2.6.Опис алгоритму рішення задачі 6
3. Виконання програми 10
4. Висновок 11
5. Список використаних джерел 12
6. Додаток А Схема алгоритму програми 13
7. Додаток Б Лістинг програми 14
1
2
КП.ХПТК. 00481 - 25 81 01
вступ
2
3
КП.ХПТК. 00481 - 25 81 01
2 Технічні характеристики
2.1 Постановка задачі
Мій курсовий проект «Утиліта Секундомір для операційної системи
Windows» полягає у написанні программи, яка зможе вимірювати час.
Створення цієї програми необхідно для того щоб користувач зміг
засікати час.
Пограмма повинна вміти
-засікати час
-збрасувати час
-зупиняти час
Данна утиліта має працювати на операційній системі Windows, на данний момент
ця ОС є найпоширинішою серед користувачів компю’терів.при включені утиліти
вона демонструє таймер з кнопками для користування.
milliseconds
3
4
КП.ХПТК. 00481 - 25 81 01
HTML
4
5
КП.ХПТК. 00481 - 25 81 01
CSS
5
6
КП.ХПТК. 00481 - 25 81 01
JavaScript.
JavaScript (JS) — динамічна, об'єктно-орієнтована[4] прототипна мова
програмування. Реалізація стандарту ECMAScript. Найчастіше використовується
для створення сценаріїв вебсторінок, що надає можливість на
боці клієнта (пристрої кінцевого користувача) взаємодіяти з користувачем,
керувати браузером, асинхронно обмінюватися даними з сервером,
змінювати структуру та зовнішній вигляд вебсторінки.
6
7
КП.ХПТК. 00481 - 25 81 01
class State {
constructor(startTimestamp, difference, suspended) {
this.startTimestamp = startTimestamp;
this.difference = difference;
this.suspended = suspended;
}
static ready() {
return new State(null, 0, 0);
}
}
7
8
КП.ХПТК. 00481 - 25 81 01
static ready() {
return new Stopwatch(State.ready());
8
9
КП.ХПТК. 00481 - 25 81 01
setState(newState) {
this.state = { ...this.state, ...newState };
this.render();
}
tick() {
this.setState({
difference: new Date(new Date() - this.state.startTimestamp)
});
this.requestAnimationId = requestAnimationFrame(this.tick);
}
9
10
КП.ХПТК. 00481 - 25 81 01
handleClickStop() {
cancelAnimationFrame(this.requestAnimationId);
this.setState({
startTimestamp: null,
suspended: this.state.difference
});
}
render() {
const { difference } = this.state;
const hundredths = (difference
? Math.floor(difference.getMilliseconds() / 10)
:0
)
.toString()
.padStart(2, "0");
const seconds = (difference ? Math.floor(difference.getSeconds()) : 0)
.toString()
.padStart(2, "0");
const minutes = (difference ? Math.floor(difference.getMinutes()) : 0)
.toString()
10
11
КП.ХПТК. 00481 - 25 81 01
.padStart(2, "0");
// Render screen
document.getElementById("minutes").textContent = minutes;
document.getElementById("seconds").textContent = seconds;
document.getElementById("hundredths").textContent = hundredths;
}
}
11
12
КП.ХПТК. 00481 - 25 81 01
Виконання програми
При відкридті веб сторінки перед вами з’явится сторінка на якій буде
секундомір.У ньому є три функції Start,stop,reset.При натиску на кнопку Start
почнется відлік часу зупинити його можна за допомогою кнопки stop,такой є
функція скидання часу reset.
12
13
КП.ХПТК. 00481 - 25 81 01
Висновок
В даному курсовому проекті розроблена програма Утиліта «Секундомір» для
операційної системи Windows.
В результаті розробки проекту я розширив свої знання в сфері ОС Windows, та як
з ним працювати за допомогою мови програмування Html,CSS,JS.
Також я здобув багато навичків у написанні програм на мовах Html,CSS,JS.
13
14
КП.ХПТК. 00481 - 25 81 01
14
15
КП.ХПТК. 00481 - 25 81 01
15
16
КП.ХПТК. 00481 - 25 81 01
Додаток б
Файл secundomer.html
<!doctype html>
<html>
<head>
<title>Stopwatch</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<h1 class="screen">
<span id="minutes">
00
</span>:<span id="seconds">
00
</span>:<span id="hundredths">
00
</span>
</h1>
<div class="buttons">
<button id="start">START</button>
<button id="stop">STOP</button>
<button id="reset">RESET</button>
16
17
КП.ХПТК. 00481 - 25 81 01
</div>
</div>
<script src="script.js"></script>
</body>
</html>
Файл script.js
class State {
constructor(startTimestamp, difference, suspended) {
this.startTimestamp = startTimestamp;
this.difference = difference;
this.suspended = suspended;
}
static ready() {
return new State(null, 0, 0);
}
}
class Stopwatch {
constructor(state) {
this.state = state;
this.requestAnimationId = null;
this.handleClickStart = this.handleClickStart.bind(this);
document
.getElementById("start")
.addEventListener("click", this.handleClickStart);
this.handleClickStop = this.handleClickStop.bind(this);
document
17
18
КП.ХПТК. 00481 - 25 81 01
.getElementById("stop")
.addEventListener("click", this.handleClickStop);
this.handleClickReset = this.handleClickReset.bind(this);
document
.getElementById("reset")
.addEventListener("click", this.handleClickReset);
this.tick = this.tick.bind(this);
this.render();
}
static ready() {
return new Stopwatch(State.ready());
}
setState(newState) {
this.state = { ...this.state, ...newState };
this.render();
}
tick() {
this.setState({
difference: new Date(new Date() - this.state.startTimestamp)
});
this.requestAnimationId = requestAnimationFrame(this.tick);
}
handleClickStart() {
if (this.state.startTimestamp) {
// Prevent multi clicks on start
18
19
КП.ХПТК. 00481 - 25 81 01
return;
}
this.setState({
startTimestamp: new Date() - this.state.suspended,
suspended: 0
});
this.requestAnimationId = requestAnimationFrame(this.tick);
}
handleClickStop() {
cancelAnimationFrame(this.requestAnimationId);
this.setState({
startTimestamp: null,
suspended: this.state.difference
});
}
handleClickReset() {
cancelAnimationFrame(this.requestAnimationId);
this.setState(State.ready());
}
render() {
const { difference } = this.state;
const hundredths = (difference
? Math.floor(difference.getMilliseconds() / 10)
:0
)
.toString()
19
20
КП.ХПТК. 00481 - 25 81 01
.padStart(2, "0");
const seconds = (difference ? Math.floor(difference.getSeconds()) : 0)
.toString()
.padStart(2, "0");
const minutes = (difference ? Math.floor(difference.getMinutes()) : 0)
.toString()
.padStart(2, "0");
// Render screen
document.getElementById("minutes").textContent = minutes;
document.getElementById("seconds").textContent = seconds;
document.getElementById("hundredths").textContent = hundredths;
}
}
файл style.css
html {
height: 100%;
font-family: "Roboto Condensed", sans-serif;
}
body {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-image: url(ghul.jpg);
20
21
КП.ХПТК. 00481 - 25 81 01
.container {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
padding: 15px;
border-radius: 5px;
background-color: #FF1493;
}
.screen {
margin: 0;
background-color: #cfcfcf;
color: #4B0082;
font-size: 64px;
border-radius: 5px;
padding: 10px;
cursor: default;
user-select: none;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.screen span {
display: inline-block;
width: 85px;
text-align: center;
}
.buttons {
display: flex;
21
22
КП.ХПТК. 00481 - 25 81 01
.buttons button {
flex: 1;
margin: 0 5px;
border: none;
font-size: 20px;
padding: 5px;
border-radius: 5px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
font-weight: bold;
color: #800080;
background-color: #000000;
outline: none;
cursor: pointer;
}
.buttons button:hover {
color: #000000;
background-color: #061539;
}
22