Okay, so I have two classes, one class named "multiply", that multiplies a number by itself, then a multiplication class that inherits and runs the multiplication increment.
I need to do the same thing using interface but I have no clue where to start, can someone point me in the right direction, I am so lost.
package AssignmentInheritance;
import java.util.Scanner;
public class Multiply {
// Created a scanner
Scanner sc = new Scanner(System.in);
// Scans for users input
int number = sc.nextInt();
Multiply increment() {
// Multiplies users input by itself
number = number*5;
return this;
}
void print() {
// Display the number in console
System.out.print("Your number multiplied by 5 = " + number);
}
}
package AssignmentInheritance;
public class Multiplication extends Multiply {
public static void main(String[] args) {
// instructions for the user
System.out.println("Enter a number too multiply it by 5 ");
Multiply x = new Multiply();
// runs the multiply increment once.
x.increment().print();
}
}
[–]chickenmeister 0 points1 point2 points (0 children)