Hi there, I'm new to this site and java programming, and this is my first given assignment. Define a class named Asset to store the details of an asset in the company. Each object of Asset should store the information. The Asset class should include a no-argument constructor, a constructor with parameters, appropriate setter and getter methods. Write a driver program that tests the various operations of the class. I get 6 errors of non-static method cannot be referenced from a static context.
import java.util.Scanner; public class Asset{ private String assetID; private String description; private String date; private int orderNum; private double cost; private String status; public Asset(){ } public Asset(String assetID, String description, String date, int orderNum, double cost, String status){ this.assetID = assetID; this.description = description; this.date = date; this.orderNum = orderNum; this.cost = cost; this.status = status; } public void setAssetID(String assetID){ this.assetID = assetID; } public void setDescription(String description){ this.description = description; } public void setDate(String date){ this.date = date; } public void setOrderNum(int orderNum){ this.orderNum = orderNum; } public void setCost(double cost){ this.cost = cost; } public void setStatus(String status){ this.status = status; } public String getAssetID(){ return assetID; } public String getDescription(){ return description; } public String getDate(){ return date; } public int getOrderNum(){ return orderNum; } public double getCost(){ return cost; } public String getStatus(){ return status; } } class TestAsset{ public static void main(String [] args){ Scanner s = new Scanner(System.in); String assetID; String description; String date; int orderNum; double cost; String status; System.out.print("Enter asset ID: "); assetID = s.next(); System.out.print("Enter the description: "); description = s.next(); System.out.print("Enter the date: "); date = s.next(); System.out.print("Enter the order number: "); orderNum = s.nextInt(); System.out.print("Enter the cost: "); cost = s.nextDouble(); System.out.print("Enter the status: "); status = s.next(); System.out.print("Asset ID: " + Asset.getAssetID()); System.out.print("Description: " + Asset.getDescription()); System.out.print("Date: " + Asset.getDate()); System.out.print("Order number: " + Asset.getOrderNum()); System.out.print("Cost: " + Asset.getCost()); System.out.print("Status: " + Asset.getStatus()); } }
Any guideline will be appreciated.