java3

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java3相关的知识,希望对你有一定的参考价值。

class Address{
private String guojia;
private String shengfen;
private String chengshi;
private String jiedao;
private int youbian;
public Address(){

}
public Address(String guojia,String shengfen,String chengshi,String jiedao,int youbian){
this.setGuojia(guojia);
this.setShengfen(shengfen);
this.setChengshi(chengshi);
this.setJiedao(jiedao);
this.setYoubian(youbian);
}
public void setGuojia(String g){
guojia=g;
}
public void setShengfen(String s){
shengfen=s;
}
public void setChengshi(String c){
chengshi=c;
}
public void setJiedao(String j){
jiedao=j;
}
public void setYoubian(int y){
youbian=y;
}
public String getGuojia(){
return guojia;
}
public String getShengfen(){
return shengfen;
}
public String getChengshi(){
return chengshi;
}
public String getJiedao(){
return jiedao;
}
public int getYoubian(){
return youbian;
}
}
public class dizhi {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Address stu=null;
stu=new Address("中国","北京","北京","牛栏山",030032);
System.out.println("国家:"+stu.getGuojia());
System.out.println("省份:"+stu.getShengfen());
System.out.println("城市:"+stu.getChengshi());
System.out.println("街道:"+stu.getJiedao());
System.out.println("邮编:"+stu.getYoubian());
}

}

技术分享

class Employee{
private String bianhao;
private String xingming;
private float jixin;
public Employee(){

}
public Employee(String bianhao,String xingming,float jixin){
this.setBianhao(bianhao);
this.setXingming(xingming);
this.setJixin(jixin);
}
public void setBianhao(String b){
bianhao=b;
}
public void setXingming(String x){
xingming=x;
}
public void setJixin(float j){
jixin=j;
}
public String getBianhao(){
return bianhao;
}
public String getXingming(){
return xingming;
}
public float getJixin(){
return jixin;
}
public float getZengxin(){
return jixin*0.2f;
}
public float getZong(){
return jixin+getZengxin();
}
}
public class gongzi {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Employee stu=null;
stu=new Employee("M-A","张三",2000f );
System.out.println("编号:"+stu.getBianhao());
System.out.println("姓名:"+stu.getXingming());
System.out.println("基本薪水:"+stu.getJixin());
System.out.println("薪水增长额:"+stu.getZengxin());
System.out.println("工资总额:"+stu.getZong());
}

}

技术分享

class Dog{
private String name;
private String color;
private int old;
public Dog(){

}
public Dog(String name,String color,int old){
this.setName(name);
this.setColor(color);
this.setOld(old);
}
public void setName(String n){
name=n;
}
public void setColor(String c){
color=c;
}
public void setOld(int o){
old=o;
}
public String getName(){
return name;
}
public String getColor(){
return color;
}
public int getOld(){
return old;
}
}
public class xinxi{

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Dog stu=null;
stu=new Dog("李四","红",20);
System.out.println("姓名:"+stu.getName());
System.out.println("颜色:"+stu.getColor());
System.out.println("年龄:"+stu.getOld());
}

}

技术分享

class User{
private String name;
private String kouling;
private int gs;
public User(){
}
public User(String name,String kouling,int gs){
this.setName(name);
this.setKouling(kouling);
this.setGs(gs);
}
public void setName(String n){
name=n;
}
public void setKouling(String k){
kouling=k;
}

public void setGs(int g){
gs=g;
}
public String getName(){
return name;
}
public String getKouling(){
return kouling;
}
public int getGs(){

return gs;
}
}
public class yonghu {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
User stu=null;
stu=new User("张三","zhangsan",1);
System.out.println("用户名:"+stu.getName());
System.out.println("口令:"+stu.getKouling());
System.out.println("用户个数:"+stu.getGs());

}

}

技术分享

以上是关于java3的主要内容,如果未能解决你的问题,请参考以下文章