zoukankan      html  css  js  c++  java
  • 作业3

    class Book1{
    private String name;
    private int id;
    private float price;
    private static int num=3;
    private static int count=0;
    public Book1(){
    count++;
    this.id=count;
    }
    public Book1(int id){
    this.id=id;
    }
    public int getId(){
    return this.id;
    }
    public Book1(String name,float price){
    this.name=name;
    this.price=price;
    this.num=num;
    }
    public void setName(String name){
    this.name=name;
    }
    public String getName(){
    return this.name;
    }
    public void setPrice(float price){
    this.price=price;
    }
    public float getPrice(){
    return this.price;
    }
    public void setNum(int num){
    this.num=num;
    }
    public int getNum(){
    return this.num;
    }
    }
    public class sjx06 {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Book1 book[]=new Book1[6];
    book[0]=new Book1("java教程 ",99.9f);
    book[1]=new Book1("java web 教程 ",69.9f);
    book[2]=new Book1("java EE 教程 ",67.9f);
    book[3]=new Book1("android 教程 ",56.8f);
    book[4]=new Book1("Mysql 教程 ",56.5f);
    book[5]=new Book1("oracle 教程 ",78.7f);
    for(int i=0;i<book.length;i++){
    System.out.println("编号:"+new Book1().getId()
    +" 书名:"+book[i].getName()
    +" 价格:"+book[i].getPrice()
    +" 数量:"+book[i].getNum());
    }
    System.out.println("图书总量为:"+(new Book1().getId()-1)*book[1].getNum());
    }
    }

  • 相关阅读:
    洛谷-P5729 【深基5.例7】工艺品制作
    洛谷-P5728 【深基5.例5】旗鼓相当的对手
    洛谷-P5727 【深基5.例3】冰雹猜想
    洛谷-P1720 月落乌啼算钱
    洛谷-P4956 [COCI2017-2018#6] Davor
    洛谷-P1075 质因数分解
    洛谷-P1420 最长连号
    洛谷-P1307 数字反转
    回调地址
    OAuth 2.0
  • 原文地址:https://www.cnblogs.com/hell/p/5320229.html
Copyright © 2011-2022 走看看