Repository navigation
Adding Shape and Movies projects. #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jdjBolivia
wants to merge
7
commits into
SeleniumCourse:develop
Choose a base branch
from
jdjBolivia:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5377c07
Adding Shape and Movies projects.
jdjBolivia 4cd4464
classes are ok
jdjBolivia 4bdf7a4
Merge remote-tracking branch 'upstream/develop' into develop
jdjBolivia 2606480
Leonardo Antezana: updated my Movies and Shape classes fixing all the…
jdjBolivia 510ad3f
Leonardo: some more refactoring, check style fixes.
jdjBolivia c93583a
Leonardo: added the test class for movies.
jdjBolivia 90dc6f4
Merge branch 'develop' into develop
jdjBolivia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Adding Shape and Movies projects.
- Loading branch information
commit 5377c07f5e13037f78e012c570d97891c7116de4
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
src/main/java/com/jalasoft/selenium/leonardo/movies/Customer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| import java.util.Enumeration; | ||
| import java.util.Vector; | ||
|
|
||
| class Customer { | ||
| private String _name; | ||
| private Vector _rentals = new Vector(); | ||
|
|
||
| public Customer(String name) { | ||
| _name = name; | ||
| } | ||
|
|
||
| public void addRental(Rental arg) { | ||
| _rentals.addElement(arg); | ||
| } | ||
|
|
||
| public String getName() { | ||
| return _name; | ||
| } | ||
|
|
||
| public String statement() { | ||
| double totalAmount = 0; | ||
| int frequentRenterPoints = 0; | ||
| Enumeration rentals = _rentals.elements(); | ||
| String result = "Rental Record for " + getName() + "\n"; | ||
| while (rentals.hasMoreElements()) { | ||
| double thisAmount = 0; | ||
| Rental each = (Rental) rentals.nextElement(); | ||
| //determine amounts for each line | ||
| switch (each.getMovie().getPriceCode()) { | ||
| case Movie.REGULAR: | ||
| thisAmount += 2; | ||
| if (each.getDaysRented() > 2) | ||
| thisAmount += (each.getDaysRented() - 2) * 1.5; | ||
| break; | ||
| case Movie.NEW_RELEASE: | ||
| thisAmount += each.getDaysRented() * 3; | ||
| break; | ||
| case Movie.CHILDRENS: | ||
| thisAmount += 1.5; | ||
| if (each.getDaysRented() > 3) | ||
| thisAmount += (each.getDaysRented() - 3) * 1.5; | ||
| break; | ||
| } | ||
| // add frequent renter points | ||
| frequentRenterPoints++; | ||
| // add bonus for a two day new release rental | ||
| if ((each.getMovie().getPriceCode() == Movie.NEW_RELEASE) | ||
| && | ||
| each.getDaysRented() > 1) frequentRenterPoints++; | ||
| //show figures for this rental | ||
| result += "\t" + each.getMovie().getTitle() + "\t" + | ||
| String.valueOf(thisAmount) + "\n"; | ||
| totalAmount += thisAmount; | ||
| } | ||
| //add footer lines | ||
| result += "Amount owed is " + String.valueOf(totalAmount) + | ||
| "\n"; | ||
| result += "You earned " + String.valueOf(frequentRenterPoints) | ||
| + | ||
| " frequent renter points"; | ||
| return result; | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/jalasoft/selenium/leonardo/movies/Main.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
| Customer customer = new Customer("Test"); | ||
| customer.addRental(new Rental(new Movie("The Revenant", 1), 2)); | ||
| customer.addRental(new Rental(new Movie("Terminator", 0), 2)); | ||
| System.out.println(customer.statement()); | ||
| } | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
src/main/java/com/jalasoft/selenium/leonardo/movies/Movie.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| public class Movie { | ||
| public static final int CHILDRENS = 2; | ||
| public static final int REGULAR = 0; | ||
| public static final int NEW_RELEASE = 1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you still need to keep those constants ? |
||
| private String _title; | ||
| private int _priceCode; | ||
|
|
||
| public Movie(String title, int priceCode) { | ||
| _title = title; | ||
| _priceCode = priceCode; | ||
| } | ||
|
|
||
| public int getPriceCode() { | ||
| return _priceCode; | ||
| } | ||
|
|
||
| public void setPriceCode(int arg) { | ||
| _priceCode = arg; | ||
| } | ||
|
|
||
| public String getTitle() { | ||
| return _title; | ||
| } | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
src/main/java/com/jalasoft/selenium/leonardo/movies/Rental.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| class Rental { | ||
| private Movie _movie; | ||
| private int _daysRented; | ||
|
|
||
| public Rental(Movie movie, int daysRented) { | ||
| _movie = movie; | ||
| _daysRented = daysRented; | ||
| } | ||
|
|
||
| public int getDaysRented() { | ||
| return _daysRented; | ||
| } | ||
|
|
||
| public Movie getMovie() { | ||
| return _movie; | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/jalasoft/selenium/leonardo/movies/movieType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| /** | ||
| * Created by Automation on 3/6/2017. | ||
| */ | ||
| public abstract class movieType { | ||
|
|
||
| public double calculateAmount; | ||
| } | ||
|
|
||
|
|
||
| public class childrens extends movieType { | ||
|
|
||
| private final int priceCode = 2; | ||
|
|
||
| public childrens(){} | ||
|
|
||
| public double calculateAmount(){ | ||
|
|
||
| } | ||
| } | ||
|
|
||
| public class regular extends movieType { | ||
|
|
||
| private final int priceCode = 0; | ||
|
|
||
| public regular(){} | ||
|
|
||
| public double calculateAmount(){ | ||
|
|
||
| } | ||
| } | ||
|
|
||
| public class new_release extends movieType { | ||
|
|
||
| private final int priceCode = 1; | ||
|
|
||
| public new_release(){} | ||
|
|
||
| public double calculateAmount(){ | ||
|
|
||
| } | ||
| } | ||
|
|
47 changes: 47 additions & 0 deletions
47
src/main/java/com/jalasoft/selenium/leonardo/shape/baseShape.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| /** | ||
| * Created by Automation on 3/3/2017. | ||
| */ | ||
|
|
||
| /** calculo del area y perimetro de un circulo, cuadrado y rectangulo */ | ||
| /** 1. herencia 2. abstract class or interface 3. unit test */ | ||
| public abstract class baseShape { | ||
|
|
||
| abstract double calculateArea(); | ||
|
|
||
| abstract double calculatePerimeter(); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| public class circleShape extends baseShape { | ||
|
|
||
| } | ||
|
|
||
| public class rectangleShape extends baseShape{ | ||
| int width; | ||
|
|
||
| public float areaShape(){ | ||
| return areaShape | ||
|
|
||
| } | ||
|
|
||
| public float perimeterShape(){ | ||
|
|
||
| } | ||
|
|
||
| }public class squareShape extends rectangleShape{ | ||
|
|
||
| public float areaShape(){ | ||
|
|
||
| } | ||
|
|
||
| public float perimeterShape(){ | ||
|
|
||
| } | ||
|
|
||
| }*/ | ||
|
|
||
|
|
||
|
|
22 changes: 22 additions & 0 deletions
22
src/main/java/com/jalasoft/selenium/leonardo/shape/circleShape.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| /** | ||
| * Created by Automation on 3/3/2017. | ||
| */ | ||
| public class circleShape extends baseShape { | ||
| private double radio; | ||
|
|
||
| public circleShape(double radio){ /**constructor instanciar clase*/ | ||
| this.radio = radio; | ||
| } | ||
|
|
||
| public double calculateArea(){ | ||
| double returnValue; | ||
| return returnValue = 3.14*(this.radio*2); | ||
| } | ||
|
|
||
| public double calculatePerimeter(){ | ||
| double returnValue; | ||
| return returnValue = 2*3.14*this.radio; | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/jalasoft/selenium/leonardo/shape/rectangleShape.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| /** | ||
| * Created by Automation on 3/3/2017. | ||
| */ | ||
| public class rectangleShape extends baseShape{ | ||
| private double l; | ||
| private double w; | ||
|
|
||
| public rectangleShape(double l, double w){ /**instanciar clase*/ | ||
| this.l = l; | ||
| this.w = w; | ||
| } | ||
|
|
||
| public double calculateArea(){ | ||
| double returnValue; | ||
| return returnValue = this.l*this.w; | ||
| } | ||
|
|
||
| public double calculatePerimeter(){ | ||
| double returnValue; | ||
| return returnValue = 2*(this.l+this.w); | ||
| } | ||
|
|
||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/jalasoft/selenium/leonardo/shape/squareShape.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| /** | ||
| * Created by Automation on 3/3/2017. | ||
| */ | ||
| public class squareShape extends rectangleShape{ | ||
|
|
||
| public squareShape(double l){ /**instanciar clase*/ | ||
| super (l,l); | ||
| } | ||
|
|
||
| } |
46 changes: 46 additions & 0 deletions
46
src/test/java/com/jalasoft/selenium/leonardo/shape/circleShapeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| import static org.junit.Assert.*; | ||
|
|
||
| /** | ||
| * Created by Automation on 3/3/2017. | ||
| */ | ||
| public class circleShapeTest { | ||
|
|
||
| private static final int DELTA = 0; | ||
|
|
||
| private baseShape circle; | ||
|
|
||
| @Before | ||
| public void setUp(){ | ||
| //Given | ||
| final int radio = 5; | ||
| circle = new circleShape(radio); | ||
| } | ||
|
|
||
| @Test /**nomenclatura 1*/ | ||
| public void testCalculateAreaWhen() { | ||
|
|
||
| //when - action to test | ||
| final double actualArea = circle.calculateArea(); | ||
|
|
||
| //then - assertion | ||
| final double expectedArea = 10; | ||
| assertEquals(expectedArea, actualArea, DELTA); | ||
| } | ||
|
|
||
| @Test /**nomenclatura 2*/ | ||
| public void test_calculatePerimeter_when() { | ||
|
|
||
| //when - action to test | ||
| final double actualPerimeter = circle.calculatePerimeter(); | ||
|
|
||
| //then - assertion | ||
| final double expectedPerimeter = 10; | ||
| assertEquals(expectedPerimeter, actualPerimeter, DELTA); | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/test/java/com/jalasoft/selenium/leonardo/shape/rectangleShapeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.jalasoft.selenium; | ||
|
|
||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| import static org.junit.Assert.*; | ||
|
|
||
| /** | ||
| * Created by Automation on 3/6/2017. | ||
| */ | ||
| public class rectangleShapeTest { | ||
|
|
||
| private static final int DELTA = 0; | ||
|
|
||
| private baseShape rectangle; | ||
|
|
||
| @Before | ||
| public void setUp(){ | ||
| //Given | ||
| final double l = 5; | ||
| final double w = 7; | ||
| rectangle = new rectangleShape(l, w); | ||
| } | ||
|
|
||
| @Test /**nomenclatura 1*/ | ||
| public void testCalculateAreaWhen() { | ||
|
|
||
| //when - action to test | ||
| final double actualArea = rectangle.calculateArea(); | ||
|
|
||
| //then - assertion | ||
| final double expectedArea = 10; | ||
| assertEquals(expectedArea, actualArea, DELTA); | ||
| } | ||
|
|
||
| @Test /**nomenclatura 2*/ | ||
| public void testCalculatePerimeterWhen() { | ||
|
|
||
| //when - action to test | ||
| final double actualPerimeter = rectangle.calculatePerimeter(); | ||
|
|
||
| //then - assertion | ||
| final double expectedPerimeter = 10; | ||
| assertEquals(expectedPerimeter, actualPerimeter, DELTA); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this unnecessary class
because it will replaced by unit tests