Answered You can hire a professional tutor to get the answer.
I'm trying to call a method from a different class and am getting errors on both classes. Here is the complete source code I'm using in both classes:...
I'm trying to call a method from a different class and am getting errors on both classes.
Here is the complete source code I'm using in both classes:
package computer;
public class Computer {
private int HDD;
private String Brand;
public Computer(){}
public Computer(int HDD, String Brand) {
this.HDD = HDD;
this.Brand = Brand;
}
public int GetHDD() {
return HDD;
}
public void setHDD(int HDD) {
this.HDD = HDD;
}
public String GetBrand() {
return Brand;
}
public void SetBrand(String Brand) {
this.Brand = Brand;
}
public String toString() {
return "Computer(" + HDD + "GB, " + Brand + ")";
}
}
And
package addcomputer;
/**
*
* @author Pokemon
*/
import java.util.Scanner;
/**
*
* @author Pokemon
*/
public class AddComputer {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Enter the HDD size in your current computer");
int HDD = Integer.parseInt(in.nextLine());
System.out.print("Enter the Brand name of your Computer");
String Brand = in.nextLine();
Computer myComputer = new Computer(HDD, Brand);
System.out.println("Your current system");
System.out.println(myComputer);
System.out.print("Enter your desired HDD size");
HDD = Integer.parseInt(in.nextLine());
System.out.print("Enter the brand name you desire for your next computer");
Brand = in.nextLine();
Computer nextComputer = new Computer(HDD, Brand);
System.out.println("The computer you next plan to buy");
System.out.println(nextComputer);
in.close();
}
I have tried importing the package from the first class on the second class, and the second class doesn't recognize it as existing. Also, the first class keeps saying I need to declare a main method, but when I try it throws errors on the rest of the code.