This one works just fine
public class Brand { private String name; private String city; public Brand() { setName(""); setCity(""); } public Brand(String n, String c) { setName(n); setCity(c); } //SETS public void setName(String name) { this.name = name; } public void setCity(String city) { this.city = city; } //GETS public String getName() { return name; } public String getCity() { return city; } public String toString() { return("Name" + name + "City" + city); } }
This is the one that wont compile and I'm not sure what I have done wrong, everything looks the same as I have it in my notes.
public class Computer { private Brand brand; private double price; private int quantity; private double totalCharge; public Computer() { setBrand(new Brand()); setPrice(0.0); setQuantity(0); setTotalCharge(0.0); } public Computer(String n, String c, double p, int q, double tc) { setBrand(new Brand(n, c)); setPrice(p); setQuantity(q); setTotalCharge(tc); } //SETS public void setPrice(double price) { this.price = price; } public void setQuantity(int quantity) { this.quantity = quantity; } public void setTotalCharge(double totalCharge) { this.totalCharge = totalCharge; } //GETS public double getPrice() { return price; } public int getQuantity() { return quantity; } public double getTotalCharge() { return totalCharge; } public String toString() { return(brand.toString() + "Price" + price + "Quantity" + quantity + "Toatl Charge" + totalCharge); } }
Any help would be great, thanks in advance.