Class 方法类和对象

Class 方法类和对象,class,object,Class,Object,我不知道我的错误是我不理解课程 我读过一本java的书,但没有帮助 类、代码和方法让我感到困惑,尽管你能理解我的代码,但我会更好地理解这些东西的实际用途 public double intoxicated(double weight) { double numDrinks; numDrinks = (0.08 + 0.015) * weight / (12 * 7.5 * alcohol);

我不知道我的错误是我不理解课程

我读过一本java的书,但没有帮助 类、代码和方法让我感到困惑,尽管你能理解我的代码,但我会更好地理解这些东西的实际用途

public double intoxicated(double weight)
     {
         double numDrinks;

         numDrinks = (0.08 + 0.015) * weight / 
                  (12 * 7.5 * alcohol);
         return numDrinks;
     }


public class Beer
{
   private String name; 
   private double alcohol; 

   public String getName(){
       return name;
   }

   public void setName(String n)
   {
       this.name= name;

   }

   public double getAlcohol()
   {
       return Alcohol;

   }

   public void setAlcohol(double a)
   {
      this.age = age;

   }

   public double intoxicated(double weight)
    {
    double numDrinks;

    numDrinks = (0.08 + 0.015) * weight /
            (12 * 7.5 * alcohol);
    return numDrinks;
    }

   public static void main(String[] args)
   {
       Beer beer1 = new Beer();
       Beer beer2 = new Beer();


       beer1.setName("Cors Light");
       beer1.setAlcohol(0.042); 
       beer2.setName("Heinaken");
       beer2.setAlcohol(0.042); 

       double lightWeight = 100.0;
       double heavyWeight = 250.0; 

       double lightDrinks1 = beer1.intoxicated(lightWeight);
       System.out.println("The number of " + beer1.getName() +
               " drinks needed to make\na person weighing " +
               lightWeight + " pounds intoxicated is " + lightDrinks1);
       System.out.println();



   double heavyDrinks1 = beer1.intoxicated(heavyWeight);
   System.out.println("The number of " + beer1.getName() +
           " drinks needed to make\na person weighing " +
           heavyWeight + " pounds intoxicated is " + heavyDrinks1);
   System.out.println();


      double lightDrinks2 = beer2.intoxicated(lightWeight);
      System.out.println("The number of " + beer2.getName() +
               " drinks needed to make\na person weighing " +
               lightWeight + " pounds intoxicated is " + lightDrinks2);
       System.out.println();


       double heavyDrinks2 = beer2.intoxicated(heavyWeight);
       System.out.println("The number of " + beer2.getName() +
               " drinks needed to make\na person weighing " +
               heavyWeight + " pounds intoxicated is " + heavyDrinks2);
       System.out.println();


       Beer beer3 = new Beer();
       beer3.setName("Miller Genuine Draft Light");
       beer3.setAlcohol(0.042); // 4.2% alcohol

       lightWeight = 100.0; 
       heavyWeight = 250.0; 

       double lightDrinks3 = beer3.intoxicated(lightWeight);
       System.out.println("The number of " + beer3.getName() +
               " drinks needed to make\na person weighing " +
               lightWeight + " pounds intoxicated is " + lightDrinks3);
       System.out.println();

       double heavyDrinks3 = beer3.intoxicated(heavyWeight);
       System.out.println("The number of " + beer3.getName() +
               " drinks needed to make\na person weighing " +
               heavyWeight + " pounds intoxicated is " + heavyDrinks3);
       System.out.println();
   }
}

1.你没有提到什么错误。2.您在类之外声明了一个方法。3.好luckcan你能直观地告诉我如何改变这种感恩方式吗?将方法
陶醉
转化为课堂啤酒。另外,您仍然没有发布错误,这使得很难帮助您…酒精。java:6:error:public double-tousined(双倍重量);^酒精。java:11:错误:应为numDrinks=(0.08+0.015)*weight/^酒精。java:13:错误:返回numDrinks类型的非法开始;^酒精。java:13:错误:预期返回numDrinks;^Alcohol.java:116:错误:类、接口或枚举应为}^5错误这些是错误