Commit d0ef5853 authored by Ilya Prokhorov's avatar Ilya Prokhorov

Simulator moved into separate file

parent e5d50b99
......@@ -2,7 +2,7 @@ rm -rf build
mkdir build
cd src
cat Application.swift Bug.swift Tester.swift main.swift > ../build/bugsCountEstimation.swift
cat Application.swift Bug.swift Tester.swift Simulator.swift main.swift > ../build/bugsCountEstimation.swift
cd ..
swift build/bugsCountEstimation.swift
\ No newline at end of file
class Simulator {
static func simulate(aliceErrorFindProbability: Int, bobErrorFindProbability: Int, actualBugsCount: Int) {
// Programming process
let application = Application(name: "Best Corporate Shiny App")
for bugIndex in 0..<actualBugsCount {
let bug = Bug(name: "Bug \(bugIndex)",
description: "Bug \(bugIndex) description")
application.add(bug: bug)
}
// QA process
let testerAlice = Tester(name: "Alice", errorFindProbability: 20)
let testerBob = Tester(name: "Bob", errorFindProbability: 60)
let bugsFoundedByAlice = testerAlice.findBugs(in: application)
let bugsFoundedByBob = testerBob.findBugs(in: application)
debugPrint("Alice found \(bugsFoundedByAlice.count) bugs")
debugPrint("Bob found \(bugsFoundedByBob.count) bugs")
// Lincoln Index
let commonBugs = bugsFoundedByAlice.filter(bugsFoundedByBob.contains)
guard commonBugs.count > 0 else {
fatalError("No common bugs found, one of testers must be lazy")
}
debugPrint("Common bugs count: \(commonBugs.count)")
let lincolnIndex = (bugsFoundedByAlice.count * bugsFoundedByBob.count) / commonBugs.count
let bugsCount = application.bugsCount
print("---")
print("Estimation bugs count: \(lincolnIndex)")
print("Actual bugs count: \(bugsCount)")
}
}
// Programming process
print("\n\nBugs Estimation by Lincoln Index by demensdeum (demensdeum@gmail.com) 2018\n\n")
let application = Application(name: "Best Corporate Shiny App")
let aliceErrorFindProbability = 20
let bobErrorFindProbability = 60
let actualBugsCount = 200
let actualBugsCount = 100
for bugIndex in 0..<actualBugsCount {
let bug = Bug(name: "Bug \(bugIndex)",
description: "Bug \(bugIndex) description")
application.add(bug: bug)
}
// QA process
let testerAlice = Tester(name: "Alice", errorFindProbability: 20)
let testerBob = Tester(name: "Bob", errorFindProbability: 60)
let bugsFoundedByAlice = testerAlice.findBugs(in: application)
let bugsFoundedByBob = testerBob.findBugs(in: application)
debugPrint("Alice found \(bugsFoundedByAlice.count) bugs")
debugPrint("Bob found \(bugsFoundedByBob.count) bugs")
// Lincoln Index
var commonBugs = bugsFoundedByAlice.filter(bugsFoundedByBob.contains)
guard commonBugs.count > 0 else {
fatalError("No common bugs found, one of testers must be lazy")
}
debugPrint("Common bugs count: \(commonBugs.count)")
let lincolnIndex = (bugsFoundedByAlice.count * bugsFoundedByBob.count) / commonBugs.count
let bugsCount = application.bugsCount
debugPrint("Estimation bugs count (Lincoln Index): \(lincolnIndex)")
debugPrint("Actual bugs count: \(bugsCount)")
Simulator.simulate(aliceErrorFindProbability: aliceErrorFindProbability,
bobErrorFindProbability: bobErrorFindProbability,
actualBugsCount: actualBugsCount)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment