As you can see from Bash, I cannot access the classes from my Main program, whic
ID: 3915470 • Letter: A
Question
As you can see from Bash, I cannot access the classes from my Main program, which is called PaymentDemo which is listed last in the series of screenshots below. Each of the class files has been compiled and so has the PaymentDemo. I need for the Payment demo to create an instance of Payment and its derived classes. Am I using the right syntax to create the objects in Payment Demo?
Payment.java Payment.java CashPayment.java CreditCardPayment.java PaymentDemo.javax 2 3 @author: Aaron Lee S ok 7 import java.uti1.Scanner .ja 4 Unit 9, Chapter 7 assignments, Problem: Payment of different kinds. 8 10 ok This is the super class that CashPayment and CreditCardPayment are derived from.ok/ 12 public class Payment 13 14 15 16 private double amountofPayment; public void setAmountOfPayment (double amount) amountOfPayment amount; 18 19 20 21 public double getAmountOfPayment() 23 24 25 26 27 28 29 30 31 32 return amountOfPayment; public void paymentDetails() System.out.println("You paid $"amountOfPayment);Explanation / Answer
You ca resolve this by creating a package and putting all your java classes inside this package. Please find the detailed steps below:
--com
-----------sample
------------------payments
---------------------------Payment.java
---------------------------CashPayment.java
---------------------------CreditCardPayment.java
---------------------------PaymentDemo.java
javac Payment.java
javac CashPayment.java
javac CreditCardPayment.java
javac PaymentDemo.java
java PaymentDemo
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.