1
resposta

[Projeto] Resolução

Minha resolução do exercício

Program.cs

using Ecommerce;
using Ecommerce.Clients;
using Ecommerce.Addresses;
using Ecommerce.Products;

Order order = new Order();

order.client = new Client();
order.client.name = "André Freitas";
order.client.ssn = "12345";
order.client.email = "dre.freitas23@gmail.com";
order.client.phone = "19999683757";

order.address = new Address();
order.address.street = "West 75th Street";
order.address.neighborhood = "Woodward Avenue";
order.address.city = "Woodridge";
order.address.zipCode = "60517";
order.address.houseNumber = 1000;

order.formPayment = new Payment();
order.formPayment.formPayment = "PIX";
order.formPayment.freight = 18.30;
order.formPayment.itemPrice = 499.99;

order.quantity = 2;
order.numberOrder = "013749";

if (order.quantity <= 3)
{
    Console.WriteLine("__________Pedido do cliente__________");
    Console.WriteLine("Name: " + order.client.name);
    Console.WriteLine("Address: " + order.address.street);
    Console.WriteLine("Total items: " + order.quantity);
    Console.WriteLine("nº Order: " + order.numberOrder);
    Console.WriteLine("Value: " + order.formPayment.valueTotal());

    Console.WriteLine("Purchase completed successfully!");
} else
{
    Console.WriteLine("You exceeded the limit of items");
}

Order.cs

using Ecommerce.Clients;
using Ecommerce.Addresses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ecommerce.Products
{
    public class Order
    {
        public string numberOrder;
        public int quantity;
        public Client client;
        public Payment formPayment;
        public Address address;

    }
}

Payment.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ecommerce.Products
{
    public class Payment
    {
        public string formPayment;
        public double freight;
        public double itemPrice;
        public double totalValue;

        public double valueTotal()
        {
            if (freight > 0)
            {
                totalValue = freight + itemPrice;
                return totalValue;
            } else
            {
                totalValue = itemPrice;
                return totalValue;
            }
        }
    }
}

ProductDetails.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ecommerce.Products
{
    public class ProductDetails
    {
        public int productCode;
        public string productName;
        public string description;
        public double unityPrice;
    }
}

Client.cs

using Ecommerce.Addresses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ecommerce.Clients
{
    public class Client
    {
        public string name;
        public string ssn;
        public string email;
        public string phone;

        public Address address;
    }
}

Address.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ecommerce.Addresses
{
    public class Address
    {
        public string street;
        public string neighborhood;
        public string city;
        public string zipCode;
        public int houseNumber;
    }
}
1 resposta

Bom dia André, tudo bom?

Parabéns pela resolução do exercício, e continue a realiza-los ao longo das aulas. Foco nos estudos!

att.