This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Abstract class that other classes can implement | |
abstract class Item { | |
use(); | |
} | |
// Inherits the 'Item' class's 'use()' method | |
class Box<T> implements Item { | |
// ADT list that can contain other objects | |
List<T> contents; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
print(factorial(1)); | |
print(factorial(5)); | |
print(factorial(10)); | |
print(factorial(20)); | |
} | |
int factorial(int n) { | |
if (n <= 1) { // Base case | |
return 1; |