Alright, so today I wanted to get my hands dirty with Dart, and I figured a good way to do that was to build a simple delivery app simulation. Nothing fancy, just something to play around with the basics.
First, I fired up my editor and created a new Dart project. I named it “delivery_sim” – super original, I know. Then I jumped into the `*` file, where all the magic happens.
I started by defining a couple of classes. One for `Order`, which would hold stuff like the order ID and the items ordered. Then, I created a `Restaurant` class, which would have a name and a menu (just a simple list of strings for now).
Setting Up the Classes
It looked something like this:
class Order {
int orderId;
List<String> items;
Order(*, *);
class Restaurant {
String name;
List<String> menu;
Restaurant(*, *);
See? Nothing too crazy. Just basic Dart classes.
Next up, I needed a way to simulate the actual delivery process. So I made a `DeliveryDriver` class. This class would have a name and a method to “deliver” an order. For now, the “deliver” method would just print a message to the console.
With the classes set up, I moved on to the `main()` function. This is where I created instances of my classes and made them interact.
Putting It All Together
Inside `main()`, I did the following:
Created a `Restaurant` object.
Created an `Order` object, linking it to the restaurant.
Created a `DeliveryDriver` object.
Called the `deliver` method on the driver, passing in the order and restaurant.
And, boom! When I ran the code, it printed a message to the console, simulating the delivery process.
Of course, this is a super simplified version of a delivery app. There’s no actual tracking, no maps, no payment processing – none of that real-world stuff. But it was a fun little exercise to get me comfortable with some basic Dart concepts.
I might expand on this later, maybe add some more features. Who knows? But for now, I’m happy with my little delivery simulation.