Hi I'm writing a couple classes for a programming project for school but am having some problems with the program to test all of them. Below is the first class:
That one compiles fine, but here is my test program:
on the demo.setBrandToThisBrand(FoodV4 anotherFoodItem); line I am getting a couple errors saying "FoodV4 cannot be resolved to a variable," and "Syntax error on token "anotherFoodItem", delete this token"
It looks to me like the syntax is correct but I must be overlooking something simple. Any input is appreciated!
public class FoodV4 { private String brand; private String productName; public void setBrand(String brandIn) { brand = brandIn; } public void setProductName(String productNameIn) { productName = productNameIn; } public String getBrand() { return brand; } public String getProductName() { return productName; } public void setBrandToThisBrand(FoodV4 anotherFoodItem) { String tempSetBrandToThisBrand = anotherFoodItem.getBrand(); setBrand (tempSetBrandToThisBrand); } public FoodV4(String brandIn, String productNameIn) { brand = brandIn; productName = productNameIn; } }
That one compiles fine, but here is my test program:
import java.util.*; public class TestFoodV4 { public static void main(String [] args) { String anotherFoodItem; FoodV4 demo = new FoodV4("Oracle", "Java Flavored Substance"); demo.setBrand("Oracle"); demo.setProductName("Java Flavored Substance"); demo.getBrand(); demo.getProductName(); demo.setBrandToThisBrand(FoodV4 anotherFoodItem); PackagedFoodV4 demo2 = new PackagedFoodV4("Oracle", "Packaged Java", "oz", 16, 10.00); demo2.setUnits("oz."); demo2.setSize(16); demo2.setItemCost(10.00); demo2.getUnits(); demo2.getSize(); demo2.getItemCost(); demo2.getUnitCost(); BulkFoodV4 demo3 = new BulkFoodV4("Oracle", "Bulk Java", "oz", 7.77); demo3.setUnits("oz."); demo3.setUnitCost(7.77); demo3.getUnits(); demo3.getUnitCost(); demo3.findCost(20); } }
on the demo.setBrandToThisBrand(FoodV4 anotherFoodItem); line I am getting a couple errors saying "FoodV4 cannot be resolved to a variable," and "Syntax error on token "anotherFoodItem", delete this token"
It looks to me like the syntax is correct but I must be overlooking something simple. Any input is appreciated!