十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
public class Vehicle {
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:主机域名、虚拟主机、营销软件、网站建设、白水网站维护、网站推广。
private int speed;
private String kind;
private String color;
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public Vehicle(){
this.setSpeed(20);
this.setKind("自行车");
this.setColor("红");
}
public static void main(String[] args) {
Vehicle v = new Vehicle();
System.out.println("颜色:"+v.getKind()+" 类型:"+v.getKind()+" 速度:"+v.getSpeed());
v.setColor("黄");
v.setKind("汽车");
v.setSpeed(60);
System.out.println("颜色:"+v.getKind()+" 类型:"+v.getKind()+" 速度:"+v.getSpeed());
}
}
class bike{
String color="";
String getMes(){
return color;
}
static void main(){
bike b=new bike();
System.out.println(b.getMes());
}
}
class Bicycle {
private String brand;
private String color;
private float price;
public Bicycle() {
}
public Bicycle(String brand, String color, float price) {
this.brand = brand;
this.color = color;
this.price = price;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public void go() {
System.out.println("前进");
}
public void turn() {
System.out.println("拐弯");
}
public void stop() {
System.out.println("停车");
}
public void whistle() {
System.out.println("响铃");
}
}
public class Test {
public static void main(String[] args) {
Bicycle b1 = new Bicycle("凤凰", "红", 11);
b1.go();
b1.turn();
b1.stop();
b1.whistle();
System.out.println();
Bicycle b2 = new Bicycle();
b2.setBrand("永久");
b2.setColor("黄");
b2.setPrice(12);
b2.go();
b2.turn();
b2.stop();
b2.whistle();
}
}
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
/*********************************
* 停车场管理
* author zhang
*2013-12-13
********************************/
public class CarStopManager {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请入车牌号:");
String carno = sc.next();
CarStopManager carStopManager = new CarStopManager();
carStopManager.setCarNo(carno);//设置车牌号
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String sdate = format.format(new Date());
System.out.println("当前时间(入场时间)是: "+sdate);
System.out.println("需要开出车场吗?yes/no:");
String yesno = sc.next();
if(yesno.equals("yes")){
String edate = format.format(new Date());
System.out.println("出场时间是: "+edate);
//计算方法
carManager(2, sdate, edate,carStopManager);
}
}
/**
* 计算方法
*/
public static void carManager(int type,String starTime,
String endTime,CarStopManager carStopManager){
if(type==1){//按月收费
System.out.println("如若没有缴纳月费请缴纳800元,如若缴纳将不再提示!");
}else{
/**
* 一般不会有停车几个月的吧?先不考虑停车几年或者几个月的
*/
String sDay = starTime.substring(8,10);//入场日期(天)
String sHour = starTime.substring(11, 13);//入场小时
String sMM = starTime.substring(14,16);//入场分钟
String eDay = starTime.substring(8,10);//出场日期(天)
String eHour = endTime.substring(11, 13);//出厂小时
String eMM = endTime.substring(14,16);//出厂分钟
float money = 0;//需缴纳的费用
int shour = Integer.parseInt(sHour);
int ehour = Integer.parseInt(eHour);
int smm = Integer.parseInt(sMM);
int emm = Integer.parseInt(eMM);
int rehour = 0;//停车几个小时
if(sDay.equals(eDay)){//同一天
//当天6点到20点之间
if((shour=6 shour=20)){
if(ehour - shour=6){//6个小时之内
rehour = (ehour - shour)*60+(emm - smm);//停车多少分钟
//需要缴纳的费用 前15分钟免费 以后每15分钟1.5元
money = (rehour/15-15)*1.5f;
}else{
int hour = ehour - shour -6;//6小时除外剩余小时数
rehour = 6*60+(emm - smm);//停车多少分钟
//前15分钟免费 以后每15分钟1.5元 超过6小时15分钟2元
money = ((rehour/15-15)*1.5f)+(hour*60/2);
}
}
}else{//跨天 20点到 6点之间
//todo
}
System.out.println("您的车牌号是:"+carStopManager.getCarNo()+";\n" +
"您此次停车花费的费用是: "+money+"元");
}
}
/**
* bean属性
*/
private String carNo;//车牌号
private String startTime;//入场时间
private String endTime;//出场时间
/**
* 无参构造
*/
public CarStopManager(){
super();
}
/**
* 有参数构造
* @param carNo
* @param startTime
* @param endTime
*/
public CarStopManager(String carNo, String startTime, String endTime) {
super();
this.carNo = carNo;
this.startTime = startTime;
this.endTime = endTime;
}
/**
* 设置get方法
* @return
*/
public String getCarNo() {
return carNo;
}
/**
* 设置set方法
* @param carNo
*/
public void setCarNo(String carNo) {
this.carNo = carNo;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
}