Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Assignment-01
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
louie.bridges
Assignment-01
Commits
fe4d6264
Commit
fe4d6264
authored
Jan 07, 2019
by
louie.bridges
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assignment Part 1.
parents
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
142 additions
and
0 deletions
+142
-0
.classpath
Assignment-01/.classpath
+6
-0
.gitignore
Assignment-01/.gitignore
+1
-0
.project
Assignment-01/.project
+17
-0
org.eclipse.jdt.core.prefs
Assignment-01/.settings/org.eclipse.jdt.core.prefs
+11
-0
AssessmentPartOne.java
Assignment-01/src/AssessmentPartOne.java
+63
-0
AssessmentPartOneTest.java
Assignment-01/src/AssessmentPartOneTest.java
+44
-0
No files found.
Assignment-01/.classpath
0 → 100644
View file @
fe4d6264
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
/>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
Assignment-01/.gitignore
0 → 100644
View file @
fe4d6264
/bin/
Assignment-01/.project
0 → 100644
View file @
fe4d6264
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
Assignment-01
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
Assignment-01/.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
fe4d6264
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Assignment-01/src/AssessmentPartOne.java
0 → 100644
View file @
fe4d6264
public
class
AssessmentPartOne
{
public
class
void
biggestOfThree
(
int
num1
,
int
num2
,
int
num3
)
{
// 01 - A Gentle Start
// Debug this method so it passes the unit test.
// Add comments beside any changes you make
// I have changed it so that if num1 is grater than num2 + num3 then it will return num1 as the biggest number.
if
(
num1
>(
num2
+
num3
))
{
return
num1
;
}
// I have changed it so that if num2 is grater than num1 + num3 then it will return num2 as the biggest number.
if
(
num2
>(
num1
+
num3
))
{
return
num2
;
}
// I have changed it so that if num3 is grater than num1 + num2 then it will return num1 as the biggest number.
if
(
num3
>(
num1
+
num2
))
{
return
num3
;
}
}
public
int
sumNumbersBetween
(
int
start
,
int
end
)
{
// 02 - Adding Across A Range
// Complete this method so that it adds together all
// the integers between start and end, but not including
// start or end
// This method should only deal with 0 and positive integers
// This method should return -1 if it cannot calculate the result
// You should comment your code explaining what each part does
int
sumOfSquares
=
num1
-
num2
;
// This is a If statement I have used to deturmine the highest value.
// In this If statement I have said if num1 is less than num2 then take away num2 from num1.
if
(
num1
<
num2
)
{
sumOfSquares
=
(
num2
-
num1
);
}
// In this If statement I have said if num1 is more than num2 then take away num1 from num2.
if
(
num1
>
num2
)
{
sumOfSquares
=
(
num1
-
num2
);
}
// In this If statement I have said if num2 is less than num3 then take away num3 from num2.
if
(
num2
<
num3
)
{
sumOfSquares
=
(
num3
-
num2
);
}
// In this If statement I have said if num3 is more than num2 then take away num2 from num3.
if
(
num3
>
num2
)
{
sumOfSquares
=
(
num2
-
num3
);
}
// In this If statement I have said if num1 is less than num3 then take away num3 from num1.
if
(
num1
<
num3
)
{
sumOfSquares
=
(
num3
-
num1
);
}
return
sumOfSquares
;
}
}
Assignment-01/src/AssessmentPartOneTest.java
0 → 100644
View file @
fe4d6264
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.provider.CsvSource
;
class
AssessmentPartOneTest
{
public
static
AssessmentPartOne
test
;
@BeforeAll
static
void
setUpBeforeClass
()
throws
Exception
{
test
=
new
AssessmentPartOne
();
}
@ParameterizedTest
@DisplayName
(
"Testing biggestOfThree"
)
@CsvSource
({
"1,2,3,3"
,
"4,2,3,4"
,
"1,5,3,5"
,
"8,7,7,8"
,
"1,5,7,7"
})
void
testCountVowels
(
int
num1
,
int
num2
,
int
num3
,
int
biggest
)
{
assertEquals
(
biggest
,
test
.
biggestOfThree
(
num1
,
num2
,
num3
));
}
@ParameterizedTest
@DisplayName
(
"Testing sumNumbersBetween"
)
@CsvSource
({
"1,4,5"
,
"1,6,14"
,
"1,2,-1"
,
"-5,8,-1"
,
"5,3,-1"
,
"3,-1,-1"
})
void
testSumNumbersBetween
(
int
num1
,
int
num2
,
int
sum
)
{
assertEquals
(
sum
,
test
.
sumNumbersBetween
(
num1
,
num2
));
}
}
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