Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# Java Exercise

This is a simple exercise to allow you to demostrate your software engineering skillset. It's completly up to you how long you give yourself, stop when you're happy with the quality of your work, but we don't expect it to take too long.

## Instructions
1. Please fork this repository and work on your fork.
_https://help.github.com/en/articles/fork-a-repo_
2. Commit changes frequently so that we can review your progression with you later.
_https://crealytics.com/blog/5-reasons-keeping-git-commits-small/_
3. You should use a recognised build tool, e.g. _gradle_, _maven_...
4. We are currently using [open JDK 8u181](https://cdn.azul.com/zulu/bin/zulu8.31.0.1-jdk8.0.181-win_x64.msi). But please use the JDK you think is most appropriate to demonstrate your skillset.
5. We don't expect 100% code coverage, we expect well tested code.
_https://medium.com/@nicklee1/why-test-code-coverage-targets-are-a-bad-idea-1b9b8ef711ef_
6. Any other tools or libraries used must be freely available. Any third-party jars must be accessible via [maven central](https://mvnrepository.com/repos/central).
7. The specification is below.
This is a simple exercise done by Mehmet Sibar. The application can run via command line. It will ask a few questions to fill the shopping cart. At the end of it, the application should show your cart and the total price.

It's best to run the test to see how the application performs.

The command-line interface has not designed very well as the main focus is the code quality and logic.



## Specification

Expand All @@ -35,12 +29,6 @@ Henry’s Grocery, currently only stocks four items and has two promotions. Thes
| :--- | :---: | :---: |
| Buy 2 tins of soup and get a loaf of bread half price | yesterday | for 7 days |
| Apples have a 10% discount | from 3 days hence | until the end of the following month |

### Inputs
All basket items added via the command prompt.

### Outputs
All outputs must print to the command line.

### Tests
- Price a basket containing: 3 tins of soup and 2 loaves of bread, bought today,
Expand Down
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
id 'java'
}

group 'com.ford.exercise'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'org.hamcrest', name: 'java-hamcrest', version: '2.0.0.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
Binary file added build/classes/java/main/cart/ShoppingCart.class
Binary file not shown.
Binary file added build/classes/java/main/item/Item.class
Binary file not shown.
Binary file added build/classes/java/main/item/PriceCalculator.class
Binary file not shown.
Binary file added build/classes/java/main/item/Unit.class
Binary file not shown.
Binary file added build/classes/java/test/unit/GroceryTest.class
Binary file not shown.
387 changes: 387 additions & 0 deletions build/reports/tests/test/classes/unit.GroceryTest.html

Large diffs are not rendered by default.

179 changes: 179 additions & 0 deletions build/reports/tests/test/css/base-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@

body {
margin: 0;
padding: 0;
font-family: sans-serif;
font-size: 12pt;
}

body, a, a:visited {
color: #303030;
}

#content {
padding-left: 50px;
padding-right: 50px;
padding-top: 30px;
padding-bottom: 30px;
}

#content h1 {
font-size: 160%;
margin-bottom: 10px;
}

#footer {
margin-top: 100px;
font-size: 80%;
white-space: nowrap;
}

#footer, #footer a {
color: #a0a0a0;
}

#line-wrapping-toggle {
vertical-align: middle;
}

#label-for-line-wrapping-toggle {
vertical-align: middle;
}

ul {
margin-left: 0;
}

h1, h2, h3 {
white-space: nowrap;
}

h2 {
font-size: 120%;
}

ul.tabLinks {
padding-left: 0;
padding-top: 10px;
padding-bottom: 10px;
overflow: auto;
min-width: 800px;
width: auto !important;
width: 800px;
}

ul.tabLinks li {
float: left;
height: 100%;
list-style: none;
padding-left: 10px;
padding-right: 10px;
padding-top: 5px;
padding-bottom: 5px;
margin-bottom: 0;
-moz-border-radius: 7px;
border-radius: 7px;
margin-right: 25px;
border: solid 1px #d4d4d4;
background-color: #f0f0f0;
}

ul.tabLinks li:hover {
background-color: #fafafa;
}

ul.tabLinks li.selected {
background-color: #c5f0f5;
border-color: #c5f0f5;
}

ul.tabLinks a {
font-size: 120%;
display: block;
outline: none;
text-decoration: none;
margin: 0;
padding: 0;
}

ul.tabLinks li h2 {
margin: 0;
padding: 0;
}

div.tab {
}

div.selected {
display: block;
}

div.deselected {
display: none;
}

div.tab table {
min-width: 350px;
width: auto !important;
width: 350px;
border-collapse: collapse;
}

div.tab th, div.tab table {
border-bottom: solid #d0d0d0 1px;
}

div.tab th {
text-align: left;
white-space: nowrap;
padding-left: 6em;
}

div.tab th:first-child {
padding-left: 0;
}

div.tab td {
white-space: nowrap;
padding-left: 6em;
padding-top: 5px;
padding-bottom: 5px;
}

div.tab td:first-child {
padding-left: 0;
}

div.tab td.numeric, div.tab th.numeric {
text-align: right;
}

span.code {
display: inline-block;
margin-top: 0em;
margin-bottom: 1em;
}

span.code pre {
font-size: 11pt;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
margin: 0;
background-color: #f7f7f7;
border: solid 1px #d0d0d0;
min-width: 700px;
width: auto !important;
width: 700px;
}

span.wrapped pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: break-all;
}

label.hidden {
display: none;
}
84 changes: 84 additions & 0 deletions build/reports/tests/test/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

#summary {
margin-top: 30px;
margin-bottom: 40px;
}

#summary table {
border-collapse: collapse;
}

#summary td {
vertical-align: top;
}

.breadcrumbs, .breadcrumbs a {
color: #606060;
}

.infoBox {
width: 110px;
padding-top: 15px;
padding-bottom: 15px;
text-align: center;
}

.infoBox p {
margin: 0;
}

.counter, .percent {
font-size: 120%;
font-weight: bold;
margin-bottom: 8px;
}

#duration {
width: 125px;
}

#successRate, .summaryGroup {
border: solid 2px #d0d0d0;
-moz-border-radius: 10px;
border-radius: 10px;
}

#successRate {
width: 140px;
margin-left: 35px;
}

#successRate .percent {
font-size: 180%;
}

.success, .success a {
color: #008000;
}

div.success, #successRate.success {
background-color: #bbd9bb;
border-color: #008000;
}

.failures, .failures a {
color: #b60808;
}

.skipped, .skipped a {
color: #c09853;
}

div.failures, #successRate.failures {
background-color: #ecdada;
border-color: #b60808;
}

ul.linkList {
padding-left: 0;
}

ul.linkList li {
list-style: none;
margin-bottom: 5px;
}
Loading