• 课后习题1


      1 package com.ju;
      2 
      3 public class power {
      4     
      5     //颜色
      6     private String yanse;
      7     
      8     //品牌
      9     private String pinpai;
     10     
     11     //电池容量
     12     private double mah;
     13     
     14     //当前容量
     15     private double dqmah;
     16     
     17     //充电
     18     public void chongdian(double dianliang)
     19     {
     20         if (dianliang < 0)
     21         {
     22             System.out.println("请及时充电");
     23         }
     24         else if (this.dqmah + dianliang > this.mah)
     25         {
     26             double bccd = this.mah-this.dqmah;
     27             
     28             this.dqmah = this.mah;
     29             
     30             System.out.println("已充满,请关闭充电电源" +bccd+"毫安");
     31         }
     32         else
     33         {
     34             this.dqmah += dianliang;
     35             System.out.println("这次充了"+dianliang+"毫安");
     36         }
     37     }
     38     private double xiaohao = 0;
     39     
     40     private double xiaohaozl()
     41     {
     42         return this.xiaohaozl();
     43     }
     44     
     45     //使用 消耗电量
     46     public void xiaohaodl(double xiaohaozl,double xiaohao)
     47     {
     48     
     49         if(this.dqmah <=0)
     50         {
     51             System.out.println("电量低,请充电后使用");    
     52             
     53             return;
     54         }
     55         if (xiaohaozl<0 || xiaohao<0)
     56         {
     57             System.out.println("无法使用");
     58         }
     59         if (this.dqmah < 0 )
     60         {
     61             this.dqmah = 0;
     62             
     63             System.out.println("请充电!");
     64         }
     65     }
     66     
     67     public String getYanse() {
     68         return yanse;
     69     }
     70 
     71     public void setYanse(String yanse) {
     72         this.yanse = yanse;
     73     }
     74 
     75     public String getPinpai() {
     76         return pinpai;
     77     }
     78 
     79     public void setPinpai(String pinpai) {
     80         this.pinpai = pinpai;
     81     }
     82 
     83     public double getMah() {
     84         return mah;
     85     }
     86 
     87     public void setMah(double mah) {
     88         this.mah = mah;
     89     }
     90 
     91     public double getDqmah() {
     92         return dqmah;
     93     }
     94 
     95     public void setDqmah(double dqmah) {
     96         this.dqmah = dqmah;
     97     }
     98 
     99     public power(String pinpai, double mah, double dqmah) {
    100         super();
    101         this.pinpai = pinpai;
    102         this.mah = mah;
    103         this.dqmah = dqmah;
    104     }
    105     public static void main(String[]args)
    106     {
    107         power myMi = new power("小米",20000,500);
    108         
    109         System.out.println("品牌 = "+ myMi.getPinpai());
    110         
    111         System.out.println("电量 = "+ myMi.getMah());
    112         
    113         
    114     }
    115 
    116 }
    117 
    118 }
  • 相关阅读:
    javascript 创建节点和新增节点
    javascript 操作节点的属性
    javascript window对象常用方法
    为什么要用线程池?
    一个request请求然后锁定等待异步接口处理结果
    双端队列实现串行处理实现并发
    线程池创建线程的方式一定效率高吗?
    PriorityBlockingQueue 和 Executors.newCachedThreadPool()
    核心记账业务可用jdk7的PriorityBlockingQueue优先阻塞队列结合乐观锁实现
    对spring、AOP、IOP的理解 (转)
  • 原文地址:https://www.cnblogs.com/TENOKAWA/p/5247792.html
Copyright © 2020-2023  润新知