Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lab3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mrsl2000
Lab3
Commits
c189abcf
Commit
c189abcf
authored
Mar 14, 2019
by
mrsl2000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add logic package and logic test
parent
5b7ab442
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
ClockLogic.java
src/org/clock/logic/ClockLogic.java
+51
-0
ClockLogicTest.java
src/test/ClockLogicTest.java
+25
-0
No files found.
src/org/clock/logic/ClockLogic.java
0 → 100644
View file @
c189abcf
package
org
.
clock
.
logic
;
public
class
ClockLogic
{
private
int
hour
;
private
int
minute
;
private
int
second
;
public
ClockLogic
()
{
this
.
hour
=
0
;
this
.
minute
=
0
;
this
.
second
=
0
;
}
public
ClockLogic
(
int
hour
,
int
minute
,
int
second
)
{
this
.
hour
=
hour
;
this
.
minute
=
minute
;
this
.
second
=
second
;
}
public
void
setClock
(
int
hour
,
int
minute
,
int
second
)
{
this
.
hour
=
hour
;
this
.
minute
=
minute
;
this
.
second
=
second
;
}
public
void
tik
(
int
second
)
{
this
.
second
+=
second
%
60
;
second
=
second
/
60
;
this
.
minute
+=
second
%
60
;
second
=
second
/
60
;
this
.
hour
+=
second
;
if
(
this
.
second
>
60
)
{
minute
++;
this
.
second
%=
60
;
}
if
(
this
.
minute
>
60
)
{
hour
++;
this
.
minute
%=
60
;
}
if
(
this
.
hour
>
24
)
{
this
.
hour
%=
24
;
}
}
public
int
getHour
()
{
return
hour
;
}
public
int
getMinute
()
{
return
minute
;
}
public
int
getSecond
()
{
return
second
;
}
}
src/test/ClockLogicTest.java
0 → 100644
View file @
c189abcf
package
test
;
import
org.clock.logic.ClockLogic
;
public
class
ClockLogicTest
{
public
static
void
main
(
String
[]
args
)
{
ClockLogic
clockLogic
=
new
ClockLogic
(
1
,
2
,
3
);
System
.
out
.
println
(
clockLogic
.
getSecond
()
==
3
);
System
.
out
.
println
(
clockLogic
.
getMinute
()
==
2
);
System
.
out
.
println
(
clockLogic
.
getHour
()
==
1
);
clockLogic
.
setClock
(
10
,
20
,
30
);
System
.
out
.
println
(
clockLogic
.
getSecond
()
==
30
);
System
.
out
.
println
(
clockLogic
.
getMinute
()
==
20
);
System
.
out
.
println
(
clockLogic
.
getHour
()
==
10
);
clockLogic
.
tik
(
1
);
System
.
out
.
println
(
clockLogic
.
getSecond
()
==
31
);
System
.
out
.
println
(
clockLogic
.
getMinute
()
==
20
);
System
.
out
.
println
(
clockLogic
.
getHour
()
==
10
);
clockLogic
.
setClock
(
10
,
20
,
0
);
clockLogic
.
tik
(
100
);
System
.
out
.
println
(
clockLogic
.
getSecond
()
==
40
);
System
.
out
.
println
(
clockLogic
.
getMinute
()
==
21
);
System
.
out
.
println
(
clockLogic
.
getHour
()
==
10
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment