{"id":19659752,"url":"https://github.com/maicius/twhomeproject2018","last_synced_at":"2026-05-10T23:36:29.039Z","repository":{"id":82733639,"uuid":"107133164","full_name":"Maicius/TWHomeProject2018","owner":"Maicius","description":"Thoughtworks 2018校园招聘作业","archived":false,"fork":false,"pushed_at":"2017-10-17T02:50:56.000Z","size":118,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T01:27:20.227Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Maicius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-16T13:44:52.000Z","updated_at":"2017-10-17T02:27:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"cba5b0a3-35ec-4e51-8164-137ce9944804","html_url":"https://github.com/Maicius/TWHomeProject2018","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maicius%2FTWHomeProject2018","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maicius%2FTWHomeProject2018/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maicius%2FTWHomeProject2018/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maicius%2FTWHomeProject2018/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Maicius","download_url":"https://codeload.github.com/Maicius/TWHomeProject2018/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240968788,"owners_count":19886375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T15:44:17.140Z","updated_at":"2026-05-10T23:36:28.982Z","avatar_url":"https://github.com/Maicius.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ThoughtWorks 2018校园招聘作业题目——出租车\n\n\n### 作业情况简介：\n\n\u003e Java 版本：JDK 1.8  \n\u003e IDE: IntelliJ IDEA  \n\u003e 操作系统： Mac OS Sierra  \n\u003e 依赖管理：Maven  \n\u003e 版本控制：Git\n\u003e 测试：JUnit 4.12 \n\n### How to Run\n\n\u003e **注意** \n\u003e 本项目为方便输入  \n\u003e 使用了System.setIn重定向输入流到文件中  \n\u003e 测试数据写在testCase1.txt或 testCase2.txt中  \n\u003e 如需从控制台手动输入，需要取消该重定向.该代码在：  \n\u003e **com.thoughtworks.taxi.util.FormatInput.readInput(fileName)** 19行\n\n\u003e 1. 使用IDEA或Eclipse导入项目\n\u003e 2. 根据提示导入maven依赖，或者使用命令行进入项目根目录，执行： mvn install\n\u003e 3. build\n\u003e 4. 选择 package com.thoughtworks.taxi.main.hanleIO.main(String args[]) -\u003e run \n\u003e 5. 测试：一共25个测试用例，每个Java类对应的测试用例在相应的包中，测试Suite在 package com.thoughtworks.taxi.main.TestSuit中\n\u003e 6. 25个测试全部通过，表示环境正常，运行通过\n\u003e 7. 可能的Exception：  \n\u003e   FileNotFoundException: 请根据提示的文件名（如testCase1.txt）在项目根目录下确认该文件是否存在\n\n### 核心算法介绍\n\n#### 1.计算报废车辆信息：\n\n##### 算法相关代码：\n\n\u003e com.thoughtworks.taxi.core -- Calculate.class -- isWriteOff(Car car)  \n\u003e test：com.thoughtworks.taxi.core -- CalculateTest.class  \n\t\t\n\t\ttestWriteOff(); testWriteOff2();testWriteOff2()\n\n##### 算法步骤：\n  \n\u003e 1. 计算计算车辆是否经过大修，从而调整报废年限 —— writeOffYears\n\u003e 2. 计算车辆购买日期至提交日期的天数——boughtDays\n\u003e 3. 计算车辆报废日期 —— writeOffDate\n\u003e 3. 如果boughtDays \u003e= writeOffYears * 365， 则车辆已报废，不作提醒\n\u003e 4. 设置常量：两个月能达到的最大天数（62） —— maxMonthDays;开始提醒保修的提前时间（1个月）—— nearToFixMonthNum  \n\u003e 5. 计算提醒报废的条件：\n    \n    boughtDays \u003e= writeOffDays - maxMonthDays \u0026\u0026 monthSplit \u003c= nearToFixMonthNum \u0026\u0026 monthSplit \u003e=0\n    \n\u003e    即 同时满足 **报废日期距离提交日期还剩一个月内** 和 **月份的数字相差不超过 1**，极限情况为 8月31日和 7月1日，此时相差 62天，但依然该提醒\n\u003e 6. 不满足上述条件的车辆标记为New,进入按里程数提醒保修的计算\n\n#### 2. 计算需要提醒每一万公里保养的车辆\n\n##### 算法相关代码：\n\n\u003e com.thoughtworks.taxi.core -- Calculate.class -- isDistanceRelated(Car car）   \n\u003e test：com.thoughtworks.taxi.core -- CalculateTest.class\n \n    testIsDistanceRelated()；testIsDistanceRelated2()  \n    \n##### 算法步骤：\n\n\u003e 在算法1中被标记为New的车辆，进入此次计算\n  \n\u003e 1. 设置常量：里程数(10000) —— distanceKilos， 开始提醒的里程数(500) ——(distanceRemindBegin)\n\n\u003e 2. 计算提醒条件：\n\n\t(car.getKilos() % distanceKilos) == 0 || distanceKilos - (car.getKilos() % distanceKilos) \u003c= distanceRemindBegin\n\t\n\u003e 即满足汽车里程数为 10000的整数倍或者对10000取余后，余数在 9500 - 10000之间\n\u003e 不满足条件的汽车返回 false,进入按时间提醒保修的计算\n\n#### 3. 计算需要定期保养的车辆\n\n##### 算法相关代码：\n\n\u003e com.thoughtworks.taxi.core -- Calculate.class -- isTimeRelated(Car car)  \n\u003e test: com.thoughtworks.taxi.core -- CalculateTest.class\n\n\t\ttestIsTimeRelated();testIsTimeRelated2();\n\n##### 算法步骤：\n\n\u003e 1. 计算汽车购买年限，根据年限调整保修周期——fixSplit\n\n\u003e 2. 忽略掉具体日期之后计算两个日期间的月份差距 —— monthSplit\n\n\u003e 3. 计算公式：\n\n\t(monthSplit % fixSplit) \u003c= 1\n   \n\u003e 即 monthSplit 对 fixSplit取余，余数表示距离下一个维修周期还剩的月数\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaicius%2Ftwhomeproject2018","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaicius%2Ftwhomeproject2018","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaicius%2Ftwhomeproject2018/lists"}