これが私のプログラムです。this.pizzaorder[i].clone()
またはがあるところはどこでも、タイプthis.pizzaorder[count].clone()
の from が表示されないというエラーが表示されます。何か助けてください。Clone()
Object
import java.text.NumberFormat;
public class PizzaOrder {
NumberFormat moneyFormatter = NumberFormat.getCurrencyInstance();
public int TotalNoOfPizzas, keep;
//declaring the variables needed for this class
public double totalcost;
Pizza[] pizzaorder = new Pizza[TotalNoOfPizzas];
int i;
public PizzaOrder() {
//constructor to initialize all the varibales
this.TotalNoOfPizzas = 0;
this.totalcost = 0.0;
for ( i = 1; i <= pizzaorder.length; i++ ) {
pizzaorder[i] = null; }
}
public PizzaOrder( PizzaOrder keep ) {
// copy constructor
for ( i = 1; i <= pizzaorder.length; i++) {
this.pizzaorder[i] = this.pizzaorder[i].clone(); }
this.TotalNoOfPizzas = keep.TotalNoOfPizzas;
this.totalcost = keep.totalcost; }
public int getTotalNoOfPizzas() {
//using Accessor to get the number of pizzas
return this.TotalNoOfPizzas; }
public void setTotalNoOfPizzas( int TotalNoOfPizzas1 ) {
//using mutators to set the number of pizzas
this.TotalNoOfPizzas = TotalNoOfPizzas1; }
public Pizza getPizza ( int pizzas) {
//using Accessor to get the size and toppings for pizza 1
return (this.pizzaorder[pizzas]); }
public void setPizza(Pizza tempPizza, int count) {
this.pizzaorder[count].clone(); }
public double getTotalCost() {
return(this.totalcost); }
public void setTotalCost(double totalcost1) {
this.totalcost = totalcost1; }
public double calcTotal() {
//calculating the total cost
double totalcostoford = 0;
for (i = 1; i <= pizzaorder.length; i++) {
totalcostoford += this.pizzaorder[i].calcCost(); }
return totalcostoford; }
public String tostring() {
String pizzaDescription;
pizzaDescription = "\n Order No.:" + this.pizzaorder;
pizzaDescription +="\nTotal No. of pizza's ordered:" + TotalNoOfPizzas;
for ( i = 0; i <= pizzaorder.length; i++ ) {
pizzaDescription += "\n" + i + ". Pizza" +
pizzaorder[i].getPizzaDescription(); }
pizzaDescription += "\n" + moneyFormatter.format(this.getTotalCost()) + "is your
total price.";
return pizzaDescription;
}
}