Hi everyone. So I have edited this post with another assignment that I'm working on. I am writing a class called bandBooster that contains methods to update candy sales. So my question is how do I use the class that I created below to implement it into another program. When I try to write another program, the method names are not recognized in their. I'm using Eclipse SDK as the compiler and I know it creates a .java and a .class file. Is there something I need to do like open both files in order to use the class in another program or something?
The class that I want to use:
public class bandBooster { private String name; private int boxesSold; public void boosterName(String name) { boxesSold=0; } public String getName() { return name; } public int updateSales(int sold) { boxesSold=boxesSold+sold; return boxesSold; } public String toString() { return name + ":" + boxesSold + "boxes"; } }
This is the program that I want to use the methods from the above class in:
import java.util.Scanner; public class boosterSales { public static void main(String[] args) { name name1=new name(Joe); name name2=new name(Bob); boxesSold sold1=new sold2; boxesSold sold2=new sold2; Scanner scan=new Scanner(System.in); System.out.println("How many boxes did Joe sell this week?"); sold1=scan.nextInt(); name1.updateSales(boxesSold); System.out.println("This week Joe sold; " + boxesSold); } }