當前位置:編程學習大全網 - 電腦編程 - 求JAVA編程題答案+思路,感謝!

求JAVA編程題答案+思路,感謝!

編寫電池類(Cell):具有品牌屬性,可以續電public class Cell {private String brand;public String getBrand() {return brand;}public void setBrand(String brand) {this.brand = brand;}Cell(String brand){this.brand = brand;}public void relay() {System.out.println("正在續電.");}}編寫測試類(TestCell)import javax.swing.CellEditor;public class TestCell {public static void main(String[] args) {Cell cell = new Cell("大牌電池");System.out.println("測試結果:"+cell.getBrand());cell.relay();}}

  • 上一篇:C和指針怎麽樣
  • 下一篇:編程壹橫杠怎麽輸入
  • copyright 2024編程學習大全網