Skip to content

Commit

Permalink
Income Rate calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
amanda committed May 21, 2016
1 parent 9e40780 commit 479439b
Show file tree
Hide file tree
Showing 115 changed files with 267 additions and 84 deletions.
2 changes: 1 addition & 1 deletion TestCode/.classpath
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
Expand Down
5 changes: 5 additions & 0 deletions TestCode/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
35 changes: 0 additions & 35 deletions TestCode/WebRoot/WEB-INF/classes/.gitignore

This file was deleted.

Binary file added TestCode/WebRoot/WEB-INF/classes/Amazon.class
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/Animal.class
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/Boxes.class
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/Child.class
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/Dog.class
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/Dog1.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/EnmuTest.class
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/I_Want_coffee.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/MaxProfit.class
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/Parent.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/Shoes.class
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/TTTT.class
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/Test.class
Binary file not shown.
34 changes: 34 additions & 0 deletions TestCode/WebRoot/WEB-INF/classes/Test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
tr td{border: solid 1px red;}
</style>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<table id="main">

</table>
<script type="text/javascript">
var arr = '{"red":{"id":1,"name":"mary"},"blue":{"id":2,"name":"u71d5u5b50"}}';//u71d5u5b50这个是php中自动转换的
var dataObj = eval_r("("+arr+")");//这里要加上加好括号和双引号的原因我也不知道,就当是json语法,只能死记硬背了
$.each(dataObj,function(idx,item){
//输出
alert(item.id+"哈哈"+item.name);
var html="<tr><td>"+"id:"+"</td><td>"+dataObj[idx].id+"</td><td>"+"name:</td><td>"+dataObj[idx].name+"</td></tr>";
$("#main").html(html);
})
</script>
<!-- 另外一种读取方法 -->
<!--
<script type="text/javascript">
var d1 =[{"text":"王家湾","value":"9"},{"text":"李家湾","value":"10"},{"text":"邵家湾","value":"13"}];
$(d1).each(function(){
alert(this.text+" "+this.value);
});
</script>
-->
</script>
</body>
</html>
Binary file added TestCode/WebRoot/WEB-INF/classes/User.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/enumTest.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/ternery.class
Binary file not shown.
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/testFinal.class
Binary file not shown.
Binary file added TestCode/WebRoot/WEB-INF/classes/testOOP.class
Binary file not shown.
44 changes: 44 additions & 0 deletions TestCode/src/IncomeRateCalculator/APP.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package IncomeRateCalculator;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

import IncomeRateCalculator.Person.Gender;

public class APP {


public static void main(String[] args){







Person p1=new Person("Mike",25,500,Gender.Male);
Person p2=new Person("Derek",24,1000,Gender.Male);
Person p3=new Person("Cathy",23,2000,Gender.Female);

Set<Person> personSet=new HashSet<Person>();

personSet.add(p1);
personSet.add(p2);
personSet.add(p3);
personSet.add(new Person("Jero",60,15000,Gender.Male));


Calculator c=new Calculator();

for(Person p:personSet){
int finalRate=c.calculate(p);
System.out.println("Name: "+p.getName()+" Age: "+p.getAge()+" Gender: "+p.getGender()+" Rate: "+finalRate);
}



}


}
44 changes: 44 additions & 0 deletions TestCode/src/IncomeRateCalculator/Calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package IncomeRateCalculator;

public class Calculator {

int personIncome;
int personAge;
String gender;

int incomeRateByIncome;

int incomeRateByAge;
int incomeRateByGender;

public int calculate(Person p){

RateCalculator incomeRateCalculator=new RateCalculator();




if(p!=null){
personIncome=p.getIncome();
personAge=p.getAge();
gender=p.getGender();

incomeRateByIncome=incomeRateCalculator.calculateRateByIncome(personIncome);
incomeRateByGender=incomeRateCalculator.calculateRateByGender(gender);
incomeRateByAge=incomeRateCalculator.calculateRateByAge(personAge);


}

return this.calculateTotal();
}



public int calculateTotal(){



return incomeRateByIncome*incomeRateByGender*incomeRateByAge;
}
}
65 changes: 65 additions & 0 deletions TestCode/src/IncomeRateCalculator/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package IncomeRateCalculator;

public class Person {
private String name;
private int age;
private int income;
private Gender gender;



public enum Gender{
Male("boy"),
Female("girl");

private String gender;

Gender(String gender){
this.gender=gender;
}

public String getGender(){
return gender;
}
}




public Person(String name, int age, int income,Gender gender) {
super();
this.gender=gender;
this.name = name;
this.age = age;
this.income = income;
}

public String getGender(){
return gender.getGender();
}


public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public int getIncome() {
return income;
}

public void setIncome(int income) {
this.income = income;
}
}
62 changes: 62 additions & 0 deletions TestCode/src/IncomeRateCalculator/RateCalculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package IncomeRateCalculator;

import IncomeRateCalculator.Person.Gender;

public class RateCalculator {

public int calculateRateByIncome(int income) {

switch (income > 0 ? (income > 200 ? (income > 500 ? (income > 1000 ? 4 : 3) : 2) : 1) : -1) {

case 1:
return 1;
case 2:
return 2;
case 3:
return 5;
case 4:
return 10;
case -1:
return 0;
default:
return 0;
}

}

public int calculateRateByAge(int age) {

switch (age > 0 ? (age > 18 ? (age > 25 ? (age > 60 ? 4 : 3) : 2) : 1) : -1) {
case 1:
return 1;
case 2:
return 2;
case 3:
return 3;
case 4:
return 5;
case -1:
return 0;
default:
return 0;

}

}

public int calculateRateByGender(String gender) {

switch (gender) {
case "boy":
return 1;
case "girl":
return 2;

default:
return 0;

}

}

}
5 changes: 0 additions & 5 deletions TestCode/src/InsuranceRateCalculator/Age.java

This file was deleted.

33 changes: 0 additions & 33 deletions TestCode/src/InsuranceRateCalculator/App.java

This file was deleted.

6 changes: 0 additions & 6 deletions TestCode/src/InsuranceRateCalculator/Gender.java

This file was deleted.

5 changes: 3 additions & 2 deletions TestCode/src/Pratices/DayOfMonth.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
public enum DayOfMonth {
Jan(31,"Januery"),
Feb(28,"February"),
Mar(31,"March");

Mar(31,"March"),
April(28,"February");

private int days;
private String des;

DayOfMonth(int days,String des){
this.days=days;
this.des=des;
}

public int getDays() {
Expand Down
9 changes: 8 additions & 1 deletion TestCode/src/Pratices/DayOfMonthApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ public static void main(String[] args) {

String str= Feb.getDes();

System.out.println( );
System.out.println(Feb.getDays());
System.out.println(Feb.getDes());
System.out.println(str);


boolean compareEnumObject;

compareEnumObject=DayOfMonth.April.equals(Feb);
System.out.println(compareEnumObject);
}

}
Binary file modified TestCode/target/TestCode-0.1.1-SNAPSHOT.jar
Binary file not shown.
Loading

0 comments on commit 479439b

Please sign in to comment.