/AgileMethodologiesAIT

All my work from my second year Agile Methodologies module in AIT.

Primary LanguageJava

Agile Methodologies AIT

All my work from my second year Agile Methodologies module in AIT.

Quick Links

Week 1

  • Introduction.

Week 2

src

Problem 1:

  • Write a program that reads two integers together. Print the sum to a console window.

Screenshot 2022-02-14 at 21 18 41

Problem 2:

  • Write a program that reads and multiplies three integers together. Print the result to a console window.

Screenshot 2022-02-14 at 21 15 45

Screenshot 2022-02-14 at 21 09 39

Week 3

  • Assignment 1 work.

Week 4

src

Problem:

  • Design, implement and test an application that calculates the cost per 100 kilometers of running a car and how far a car can go with a full tank of petrol based on the following information being provided:
  1. The number of litres of petrol in the tank.
  2. The fuel efficiency in kilometers per litre.
  3. The price of petrol per litre.

Screenshot 2022-02-14 at 21 17 17

Week 5

src

Problem:

  • Write a method that converts US dollar values to Euro values based on the current exchange rate between U.S. dollars and and the Euro. On successful conversion, the Euro amount is returned.

  • You are required to:

  1. Develop appropriate User Stories,
  2. Design a suitable Product Skeleton,
  3. Employ Junit TDD process to test and develop the solution.

Screenshot 2022-02-14 at 21 14 30

class ConversionTest {
    Conversion testObj = new Conversion();

    // Test Number: 1
    // Objective: Invalid Values (Lower Range)
    // Input(s): amount = $50, rate = 0.12
    // Expected Output: -1
    @Test
    public void testConvertUSDToEuro001() {
        double actualResult = testObj.convertUSDToEuro(50, 0.12);
        assertEquals(-1, actualResult, 0.01);
    }

    // Test Number: 2
    // Objective: Valid Values
    // Input(s): amount = $750, rate = 0.88
    // Expected Output: €662.21
    @Test
    public void testConvertUSDToEuro002() {
        double actualResult = testObj.convertUSDToEuro(750, 0.88295129);
        assertEquals(662.21, actualResult, 0.01);
    }

    // Test Number: 3
    // Objective: Invalid Values (Higher Range)
    // Input(s): amount = $11750, rate = 1.80
    // Expected Output: -1
    @Test
    public void testConvertUSDToEuro003() {
        double actualResult = testObj.convertUSDToEuro(11750, 1.80);
        assertEquals(-1, actualResult, 0.01);
    }
}

Week 6

  • Worked with debugger.

Week 7

  • Reading Week - Worked on Assignment.

Week 8

src

Week 4 Problem Revisted:

Design, implement and test methods that calculates the cost per 100 kilometers of running a car and how far a car can go with a full tank of petrol based on the following information being provided:

  1. The number of litres of petrol in the tank.

  2. The fuel efficiency in kilometers per litre.

  3. The price of petrol per litre.

Use Exception Handling to handle any "error" situations that may arise.

class CarCostsTest {
    CarCosts textObj = new CarCosts();

    // Test Number: 1
    // Objective: Calculate Max Distance - Valid Values
    // Input(s): maxFuel = 50, fuelEfficiency = 17
    // Expected Output : 850
    @Test
    public void testCarCosts001() {
        try {
            double actualResult = textObj.calculateMaxDistance(50, 17);
            assertEquals(850, actualResult);
        } catch (CarCostsExceptionHandler e) {
            assertEquals("Invalid values (< 0)", e.getMessage());
        }
    }

    // Test Number: 2
    // Objective: Calculate Max Distance - Invalid Values
    // Input(s): maxFuel = -10, fuelEfficiency = -2
    // Expected Output: Exception thrown with "Invalid values (< 0)"
    @Test
    public void testCarCosts002() {
        try {
            double actualResult = textObj.calculateMaxDistance(-10, -2);
            fail("Exception expected...");
        } catch (CarCostsExceptionHandler e) {
            assertEquals("Invalid values (< 0)", e.getMessage());
        }
    }

    // Test Number: 3
    // Objective: Calculate Cost Per 100km - Valid Values
    // Input(s): petrolPrice = 1.6, fuelEfficiency = 15
    // Expected Output: 10.6
    @Test
    public void testCarCosts003() {
        try {
            double actualResult = textObj.calculateCostPerOneHundredKM(1.6, 15);
            assertEquals(10.66, actualResult, 0.01);
        } catch (CarCostsExceptionHandler e) {
            assertEquals("Invalid values (< 0)", e.getMessage());
        }
    }

    // Test Number: 4
    // Objective: Calculate Cost Per 100km - Invalid Values
    // Input(s): petrolPrice = -0.5 , fuelEfficiency = -25
    // Expected Output: Exception thrown with "Invalid values (< 0)"
    @Test
    public void testCarCosts004() {
        try {
            double actualResult = textObj.calculateCostPerOneHundredKM(-0.5, -25);
            fail("Exception expected...");
        } catch (CarCostsExceptionHandler e) {
            assertEquals("Invalid values (< 0)", e.getMessage());
        }
    }
}

Week 9

  • Worked on case design & coverage.

Week 10

src

Problem:

Employ Test Driven Development to implement the following specifications/applications. In this practical, you are required to design, implement, and execute your JUnit tests and design & implement the product skeleton. Employ TDD process discussed in class.

Specifications/Applications:

Consider an application, generate_grading, with the following specification:

The application is passed an exam mark (out of 75) and a coursework (c/w) mark (out of 25), from which it generates a grade for the course in the range 'A' to 'D'. The grade is calculated from the overall mark which is calculated as the sum of the exam and c/w marks,as follows:

  • greater than or equal to 70 - 'A'
  • greater than or equal to 50, but less than 70 - 'B'
  • greater than or equal to 30, but less than 50 - 'C'
  • less than 30 - 'D' Where a mark is outside its expected range then an exception is generated with a fault message ('FM') is generated. All inputs are passed as integers.

Design a set of tests that provide 100% Equivalence Partitioning and 100% BVA Coverage.

Screenshot 2022-03-07 at 14 40 00

class GraderTest {

    private Grader testObj = new Grader();

    // Test Number: 1
    // Objective: Generate an A grade - With Valid Values
    // Input(s): examMark = 70, courseWorkMark = 20     ---> (overallResult = 90)
    // Expected Output: A
    @Test
    public void testGrader001() {
        try {
            char actualResult = testObj.calculateGrade(70, 25);
            assertEquals('A', actualResult);
        } catch (GraderExceptionHandler e) {
            assertEquals("FM", e.getErrorMessage());
        }
    }

    // Test Number: 2
    // Objective: Generate a B grade - With Valid Values
    // Input(s): examMark = 50, courseWorkMark = 10     ---> (overallResult = 60)
    // Expected Output: B
    @Test
    public void testGrader002() {
        try {
            char actualResult = testObj.calculateGrade(50, 10);
            assertEquals('B', actualResult);
        } catch (GraderExceptionHandler e) {
            assertEquals("FM", e.getErrorMessage());
        }
    }

    // Test Number: 3
    // Objective: Generate an C grade - With Valid Values
    // Input(s): examMark = 20, courseWorkMark = 20     ---> (overallResult = 40)
    // Expected Output: C
    @Test
    public void testGrader003() {
        try {
            char actualResult = testObj.calculateGrade(20, 20);
            assertEquals('C', actualResult);
        } catch (GraderExceptionHandler e) {
            assertEquals("FM", e.getErrorMessage());
        }
    }

    // Test Number: 4
    // Objective: Generate a D grade - With Valid Values
    // Input(s): examMark = 10, courseWorkMark = 15     ---> (overallResult = 25)
    // Expected Output: D
    @Test
    public void testGrader004() {
        try {
            char actualResult = testObj.calculateGrade(10, 15);
            assertEquals('D', actualResult);
        } catch (GraderExceptionHandler e) {
            assertEquals("FM", e.getErrorMessage());
        }
    }

    // Test Number: 5
    // Objective: Generate an A grade - With Invalid values (Higher Range)
    // Input(s): examMark = 80, courseWorkMark = 30     ---> (overallResult = 110)
    // Expected Output: Exception thrown with error message "FM"
    @Test
    public void testGrader005() {
        try {
            char actualResult = testObj.calculateGrade(80, 30);
            assertEquals('A', actualResult);
        } catch (GraderExceptionHandler e) {
            assertEquals("FM", e.getErrorMessage());
        }
    }

    // Test Number: 6
    // Objective: Generate an A grade - With Invalid values (Lower Range)
    // Input(s): examMark = -10, courseWorkMark = -20   ---> (overallResult = -30)
    // Expected Output: Exception thrown with error message "FM"
    @Test
    public void testGrader006() {
        try {
            char actualResult = testObj.calculateGrade(-10, -20);
            assertEquals('A', actualResult);
        } catch (GraderExceptionHandler e) {
            assertEquals("FM", e.getErrorMessage());
        }
    }

}

Week 11

src

Assignment 2:

A year with 366 days is called a leap year. A year is a leap year if it is divisible by 4 (e.g. 1980). However, since the introduction of the Gregorian calendar on October 15, 1582, a year is not a leap year if it is divisible by 100 (e.g. 1900); however, it is a leap year if it is divisible by 400 (e.g. 2000). Write a method that computes whether a year is a leap year or not.

Follow The Procedure:
  • Develop the user story.
  • Create git repository for the project.
  • Create product skeleton.
  • Version control your product skeleton and test code.
  • Design, implement, and execute Junit tests.
  • Write product code.
  • Execute all unit tests until they all pass.
  • Version control product code.