Я очень новичок в Java, и я продолжаю получать эту ошибку, и я не могу понять это.
Ошибка: не удалось найти или загрузить основной класс
restaurantclient.RestaurantClient
Результат Java: 1
Это на Netbeans, и я уверен, что все сделал правильно. Это для моей домашней работы для класса Java, и я был бы очень признателен за вашу помощь. Я работаю над этой проблемой уже несколько дней.
import java.text.DecimalFormat;
public class RestaurantClient {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Restaurant r1;
Restaurant r2;
r1 = new Restaurant("PizzaHut", 152, (float) 4.95); //instantiating
r2 = new Restaurant("Dominos", 10, (float) 3.657);
System.out.print(r1.toString());
System.out.print(r2.toString());
r2.setPeopleServed(r1.getPeopleServed());
r2.setAveragePrice(r1.getAverageMeal());
if (r1.equals(r2)) //checking if equal
System.out.println("\nThe two objects are the same");
else
System.out.println("\nThe two objects are NOT the same");
r2.setName(r1.getName());
if (r1.equals(r2)) //checking if equal
System.out.println("\nThe two objects are the same");
else
System.out.println("\nThe two objects are NOT the same");
DecimalFormat pricePattern = new DecimalFormat("$###,###,000.00");
System.out.println("Tax paid per year: " + pricePattern.format(r1.averageTaxes()));
}
}
//Restaurant.java
public class Restaurant extends Store {
private int peopleServed;
private float avgmeal;
public Restaurant(String newName, int peopleServed, float avgmeal) {
super(newName);
setPeopleServed(peopleServed);
setAveragePrice(avgmeal);
}
public void setPeopleServed(int newpeopleServed) {
if (newpeopleServed >= 0)
peopleServed = newpeopleServed; //mutator alows client to change the value of name
else
System.out.println("Number has to be greater than zero");
}
public void setAveragePrice(float newprice) {
if (newprice >= 0)
avgmeal = newprice; //mutator alows client to change the value of name
else
System.out.println("Number has to be greater than zero");
}
public int getPeopleServed() {
return peopleServed; //accessor; returns current value
}
public float getAverageMeal() {
return avgmeal; //accessor; returns current value
}
public String toString() {
return "Name of store is: " + super.getName() +
"\nNumber of people served is " + peopleServed +
"\nAverage price per person is " + avgmeal + "\n";
}
public boolean equals(Object o) {
if (!(o instanceof Restaurant))
return false;
else {
Restaurant objRest = (Restaurant) o;
if (avgmeal == objRest.avgmeal && peopleServed == objRest.peopleServed && super.equals(objRest))
return true;
else
return false;
}
}
public double averageTaxes() {
double avgtaxes = (double)(super.taxrate * (peopleServed * avgmeal * 365));
return avgtaxes; //accessor; returns current value
}
}
//Store.java
public class Store {
private String storename;
public final float taxrate = (float) .08000;
public Store(String newName) //constructor
{
setName(newName);
}
public String getName() {
return storename; //accessor; returns current value
}
public void setName(String newName) {
storename = newName; //mutator alows client to change the value of name
}
public String toString() {
return "Name of store is: " + storename;
}
public boolean equals(Object o) {
if (!(o instanceof Store))
return false;
else {
Store objStore = (Store) o;
if (storename.equals(objStore.storename))
return true;
else
return false;
}
}
}