怎样获取另一个类中封装的属性

本文介绍了一个使用SQL构建的出差信息管理系统,包括出差开始时间、结束时间、地点、同行人员及花费等关键信息的管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

class Sql{
private String fromtime1 = "fromtime1****";    //声明出差开始时间
private String totime1 = "totime1*****";    //声明出差结束时间
private String place1 = "place1*****";    //声明出差地点
private String people1 = "people1*****";    //声明同行人员
private String cost = "cost*****";    //声明花费

public Sql(String fromtime1,String totime1,String place1,String people1,String cost){    //对用户名和密码定义构造方法并赋值
this.fromtime1 = fromtime1 ; 
this.totime1 = totime1 ; 
this.place1 = place1 ; 
this.people1 = people1 ; 
this.cost = cost ;
this.setFromtime1(fromtime1);
this.setTotime1(totime1);
this.setPlace1(place1);
this.setPeople1(people1);
this.setCost(cost);
}
public void setFromtime1(String t1){
fromtime1 = t1;
}
public void setTotime1(String t2){
totime1 = t2;
}
public void setPlace1(String p1){
place1 = p1;
}
public void setPeople1(String pe1){
people1 = pe1;
}
public void setCost(String c1){
cost = c1;
}

public String getFromtime1(){
return fromtime1;
}
public String getTotime1(){
return totime1;
}
public String getPlace1(){
return place1;
}
public String getPeople1(){
return people1;
}
public String getCost(){
return cost;
}
}
public class test2 {


public static void main(String[] args) {
// TODO 自动生成的方法存根

Sql sql =new Sql("出差开始时间", "出差结束时间", "出差地点", "同行人员", "花费");
System.out.println("出差信息:"+sql.getFromtime1()+",  "+sql.getTotime1()+",  "+sql.getPlace1()+",  "+sql.getPeople1()+",  "+sql.getCost());

}


}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值