java-Fehler: der Konstruktor in der Klasse angewendet werden kann, um bestimmte Arten

Habe ich nur noch den Konstruktor Gebäude und ich dachte, alles würde funktionieren, aber ich bekomme einen Fehler in Zeile 43. Wenn ich das Objekt erstellen Building b = new Building(); sagt er, ich muss eine double und int im argument, also ich Tat, wie er sagte, aber ich gerade immer mehr Fehler. Was mache ich falsch?

//This program lets the user design the area and stories of a building multiple times
//Author: Noah Davidson
//Date: February 20, 2014

import java.util.*;

public class Building//class begins
{
static Scanner console = new Scanner(System.in);

double area;//attributes of building
int floors;

public Building (double squarefootage, int stories)
{
area = squarefootage;
floors = stories;
}

void get_squarefootage()//user enters the area of floor
{
System.out.println ("Please enter the square footage of the floor.");
area = console.nextDouble();
}

void get_stories()//user enters the amount of floors in the building
{
System.out.println ("Please enter the number of floors in the building.");
floors = console.nextInt();
}

void get_info()//function prints outs the vaibles of the building
{
System.out.println ("The area is: " + area + " feet squared");
System.out.println ("The number of stroies in the building: " + floors + " levels");
}

public static void main(String[] args)//main starts
{
char ans;//allows for char 

  do{ //do/while loop starts so user can reiterate the program as many times as they desire
   Building b = new Building();//creates the object b
   b.get_squarefootage();//calls the user to enter the area
   b.get_stories();//calls the user to enter the floors
   System.out.println ("---------------");
   b.get_info();//displays the variables
   System.out.println ("Would you like to repeat this program? (Y/N)");
   ans = console.next().charAt(0);//user enters either Y or y until they wish to exit the program
   }while(ans == 'Y'||ans == 'y');//test of do/while loop
}
}
wenn Sie verwenden möchten neue Gebäude() , erstellen Sie einen leeren Konstruktor in der Klasse.
im soll haben Sie einen Konstruktor bauen, mit diesen zwei Parametern. Wenn ich das täte, würde es dann keine haben?
wenn Sie erstellen Sie einen Konstruktor für die Klasse(ein Konstruktor mit Argumenten), java willn nicht die Standard no-argument-Konstruktor für Ihre Klasse, so stellen Sie sicher, so dass es sich

InformationsquelleAutor NJD | 2014-03-11

Schreibe einen Kommentar