Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
L
Lab1
Project
Project
Details
Activity
Releases
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
mohamad.alturky
Lab1
Commits
a7f786a9
Commit
a7f786a9
authored
Oct 31, 2023
by
mohamad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding range calculator
parent
f38a91c0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
16 deletions
+55
-16
workspace.xml
.idea/workspace.xml
+3
-3
IFibonacciRangeCalculator.java
...bonacciSeries/abstractions/IFibonacciRangeCalculator.java
+3
-1
FibonacciRangeCalculatorUsingStructure.java
...ntation/range/FibonacciRangeCalculatorUsingStructure.java
+21
-7
FibonacciStructure.java
...in/java/FibonacciSeries/utilities/FibonacciStructure.java
+11
-5
FibonacciStructureService.java
.../FibonacciSeries/utilities/FibonacciStructureService.java
+10
-0
IFibonacciStructureService.java
...FibonacciSeries/utilities/IFibonacciStructureService.java
+7
-0
No files found.
.idea/workspace.xml
View file @
a7f786a9
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
<component
name=
"FileTemplateManagerImpl"
>
<component
name=
"FileTemplateManagerImpl"
>
<option
name=
"RECENT_TEMPLATES"
>
<option
name=
"RECENT_TEMPLATES"
>
<list>
<list>
<option
value=
"Interface"
/>
<option
value=
"Class"
/>
<option
value=
"Class"
/>
<option
value=
"Interface"
/>
</list>
</list>
</option>
</option>
</component>
</component>
...
@@ -49,11 +49,11 @@
...
@@ -49,11 +49,11 @@
</component>
</component>
<component
name=
"RunManager"
selected=
"Application.fibonacciSeries.runners.Main"
>
<component
name=
"RunManager"
selected=
"Application.fibonacciSeries.runners.Main"
>
<configuration
name=
"Main"
type=
"Application"
factoryName=
"Application"
temporary=
"true"
nameIsGenerated=
"true"
>
<configuration
name=
"Main"
type=
"Application"
factoryName=
"Application"
temporary=
"true"
nameIsGenerated=
"true"
>
<option
name=
"MAIN_CLASS_NAME"
value=
"
threading
.runners.Main"
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"
primeNumbers
.runners.Main"
/>
<module
name=
"Lab1"
/>
<module
name=
"Lab1"
/>
<extension
name=
"coverage"
>
<extension
name=
"coverage"
>
<pattern>
<pattern>
<option
name=
"PATTERN"
value=
"
threading
.runners.*"
/>
<option
name=
"PATTERN"
value=
"
primeNumbers
.runners.*"
/>
<option
name=
"ENABLED"
value=
"true"
/>
<option
name=
"ENABLED"
value=
"true"
/>
</pattern>
</pattern>
</extension>
</extension>
...
...
src/main/java/FibonacciSeries/abstractions/IFibonacciRangeCalculator.java
View file @
a7f786a9
package
fibonacciSeries
.
abstractions
;
package
fibonacciSeries
.
abstractions
;
import
fibonacciSeries.utilities.FibonacciStructure
;
import
java.util.List
;
import
java.util.List
;
public
interface
IFibonacciRangeCalculator
{
public
interface
IFibonacciRangeCalculator
{
List
<
Long
>
calculate
(
long
start
,
long
end
);
List
<
FibonacciStructure
>
calculate
(
long
start
,
long
end
);
}
}
src/main/java/FibonacciSeries/implementation/range/FibonacciRangeCalculatorUsingStructure.java
View file @
a7f786a9
package
fibonacciSeries
.
implementation
.
range
;
package
fibonacciSeries
.
implementation
.
range
;
import
fibonacciSeries.abstractions.IFibonacciRangeCalculator
;
import
fibonacciSeries.abstractions.IFibonacciRangeCalculator
;
import
fibonacciSeries.utilities.FibonacciStructure
;
import
fibonacciSeries.utilities.FibonacciStructureService
;
import
fibonacciSeries.utilities.IFibonacciStructureService
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
public
class
FibonacciRangeCalculatorUsingStructure
implements
IFibonacciRangeCalculator
{
public
class
FibonacciRangeCalculatorUsingStructure
implements
IFibonacciRangeCalculator
{
private
IFibonacciStructure
_firstItem
;
private
final
FibonacciStructure
_fZeroOfTheRange
;
private
IFibonacciStructure
_secondItem
;
private
final
FibonacciStructure
_fOneOfTheRange
;
public
FibonacciRangeCalculatorUsingStructure
(
IFibonacciStructure
_firstItem
,
IFibonacciStructure
_secondItem
)
{
public
FibonacciRangeCalculatorUsingStructure
(
FibonacciStructure
_fZeroOfTheRange
,
FibonacciStructure
_fOneOfTheRange
)
{
this
.
_f
irstItem
=
_firstItem
;
this
.
_f
ZeroOfTheRange
=
_fZeroOfTheRange
;
this
.
_
secondItem
=
_secondItem
;
this
.
_
fOneOfTheRange
=
_fOneOfTheRange
;
}
}
@Override
@Override
public
List
<
Long
>
calculate
(
long
start
,
long
end
)
{
public
List
<
FibonacciStructure
>
calculate
(
long
start
,
long
end
)
{
ArrayList
<
Long
>
result
=
new
ArrayList
<>();
IFibonacciStructureService
service
=
new
FibonacciStructureService
();
List
<
FibonacciStructure
>
result
=
new
ArrayList
<>();
FibonacciStructure
first
=
_fZeroOfTheRange
;
FibonacciStructure
second
=
_fOneOfTheRange
;
for
(
long
i
=
start
;
i
<
end
;
i
++)
{
FibonacciStructure
pushed
=
service
.
add
(
first
,
second
);
result
.
add
(
pushed
);
first
=
second
;
second
=
pushed
;
}
return
result
;
return
result
;
}
}
}
}
src/main/java/FibonacciSeries/utilities/FibonacciStructure.java
View file @
a7f786a9
...
@@ -3,15 +3,21 @@ package fibonacciSeries.utilities;
...
@@ -3,15 +3,21 @@ package fibonacciSeries.utilities;
public
class
FibonacciStructure
{
public
class
FibonacciStructure
{
private
Long
_xParameter
;
private
Long
_xParameter
;
private
Long
_yParameter
;
private
Long
_yParameter
;
private
Integer
Index
;
public
FibonacciStructure
(
Long
_xParameter
,
Long
_yParameter
,
Integer
index
)
{
public
FibonacciStructure
(
Long
_xParameter
,
Long
_yParameter
)
{
this
.
_xParameter
=
_xParameter
;
this
.
_xParameter
=
_xParameter
;
this
.
_yParameter
=
_yParameter
;
this
.
_yParameter
=
_yParameter
;
Index
=
index
;
}
}
public
Long
getFibonacciValue
(
Integer
trigger0
,
Integer
trigger1
)
{
public
Long
getXParameter
()
{
return
_xParameter
*
trigger0
+
_yParameter
*
trigger1
;
return
_xParameter
;
}
public
Long
getYParameter
()
{
return
_yParameter
;
}
public
Long
getFibonacciValue
(
Integer
xValue
,
Integer
yValue
)
{
return
_xParameter
*
xValue
+
_yParameter
*
yValue
;
}
}
}
}
src/main/java/FibonacciSeries/utilities/FibonacciStructureService.java
0 → 100644
View file @
a7f786a9
package
fibonacciSeries
.
utilities
;
public
class
FibonacciStructureService
implements
IFibonacciStructureService
{
@Override
public
FibonacciStructure
add
(
FibonacciStructure
first
,
FibonacciStructure
second
)
{
return
new
FibonacciStructure
(
first
.
getXParameter
()+
second
.
getXParameter
(),
second
.
getYParameter
()+
first
.
getYParameter
());
}
}
src/main/java/FibonacciSeries/utilities/IFibonacciStructureService.java
0 → 100644
View file @
a7f786a9
package
fibonacciSeries
.
utilities
;
public
interface
IFibonacciStructureService
{
FibonacciStructure
add
(
FibonacciStructure
first
,
FibonacciStructure
second
);
}
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