Click here to Skip to main content
15,925,602 members
Home / Discussions / C#
   

C#

 
Questionstore image in DB by Parameters.AddWithValue Pin
Member 1352250120-Sep-18 17:01
Member 1352250120-Sep-18 17:01 
AnswerRe: store image in DB by Parameters.AddWithValue Pin
OriginalGriff20-Sep-18 21:23
mveOriginalGriff20-Sep-18 21:23 
QuestionHow to modify picturebox image when clicked button Pin
mores.JR20-Sep-18 9:54
mores.JR20-Sep-18 9:54 
QuestionMessage Removed Pin
20-Sep-18 9:07
Member 1399203720-Sep-18 9:07 
Questioncommunication between two child forms in C# Pin
Member 1332584619-Sep-18 13:10
Member 1332584619-Sep-18 13:10 
AnswerRe: communication between two child forms in C# Pin
OriginalGriff19-Sep-18 19:56
mveOriginalGriff19-Sep-18 19:56 
GeneralRe: communication between two child forms in C# Pin
Member 1332584621-Sep-18 9:07
Member 1332584621-Sep-18 9:07 
GeneralRe: communication between two child forms in C# Pin
OriginalGriff21-Sep-18 23:57
mveOriginalGriff21-Sep-18 23:57 
GeneralRe: communication between two child forms in C# Pin
Member 1332584622-Sep-18 10:44
Member 1332584622-Sep-18 10:44 
GeneralRe: communication between two child forms in C# Pin
OriginalGriff22-Sep-18 21:07
mveOriginalGriff22-Sep-18 21:07 
GeneralRe: communication between two child forms in C# Pin
Member 1332584623-Sep-18 7:26
Member 1332584623-Sep-18 7:26 
GeneralRe: communication between two child forms in C# Pin
OriginalGriff23-Sep-18 7:36
mveOriginalGriff23-Sep-18 7:36 
GeneralRe: communication between two child forms in C# Pin
Member 1332584625-Sep-18 10:13
Member 1332584625-Sep-18 10:13 
Questionhow to make a gird of pictureboxs with c# Pin
mores.JR19-Sep-18 7:15
mores.JR19-Sep-18 7:15 
AnswerRe: how to make a gird of pictureboxs with c# Pin
OriginalGriff19-Sep-18 8:05
mveOriginalGriff19-Sep-18 8:05 
GeneralRe: how to make a gird of pictureboxs with c# Pin
mores.JR20-Sep-18 9:55
mores.JR20-Sep-18 9:55 
QuestionImage processing Pin
Member 266560619-Sep-18 3:39
Member 266560619-Sep-18 3:39 
AnswerRe: Image processing Pin
OriginalGriff19-Sep-18 4:18
mveOriginalGriff19-Sep-18 4:18 
AnswerRe: Image processing Pin
Pete O'Hanlon19-Sep-18 5:05
mvePete O'Hanlon19-Sep-18 5:05 
QuestionApplications settings get messed up Pin
Acuena18-Sep-18 3:32
Acuena18-Sep-18 3:32 
QuestionC# Beginner - Online Student Project Pin
Member 1398787017-Sep-18 13:14
Member 1398787017-Sep-18 13:14 
AnswerRe: C# Beginner - Online Student Project Pin
Mycroft Holmes17-Sep-18 14:17
professionalMycroft Holmes17-Sep-18 14:17 
QuestionC# help with classes and a method Pin
Member 1398782717-Sep-18 11:36
Member 1398782717-Sep-18 11:36 
I'm relearning C#, and due to my lack of funds, am using a computer that's over 5 years old and cannot even create console apps except using an online compiler. For some reason, Visual Studio will not create console apps. But that's beside the point.

I was given a file, and the task to sort out which items go on which shelf. It uses a lot of classes and arrays, my weak point in C#. So I thought I'd post here to see if someone could help me out with this.

The program itself is:
 * At ACME warehouse the warehouse manager has observed orders taking a long time to pick and
 *  believes that moving more popular items to easier to access locations may help.
 *
 * - Workers pick an order by placing items on a pallet at the dock door.
 * - Products are stored (inefficiently) in a single aisle with multiple shelves.
 * - As the shelf number increases, it is located further down the aisle and
 *   further away from the dock door.
 * - On average it takes 5*X seconds for a warehouse worker to retrieve an item
 *   from shelf X and place it on the pallet.
 * - A warehouse worker can only carry a single item at a time.
 * - A shelf can only hold one type of item.
 *
 * Which items should be on which shelves to optimize picking speed based on
 *  yesterday's orders?
 *
 *
 * Example output
 *
 * Shelf 1:      Item 12
 * Shelf 2:      Item 11
 * Shelf 3:      Item 10
 * Shelf 4:      Item 09
 * Shelf 5:      Item 08
 * Shelf 6:      Item 07
 * Shelf 7:      Item 06
 * Shelf 8:      Item 05
 * Shelf 9:      Item 04
 * Shelf 10:     Item 03
 * Shelf 11:     Item 02
 * Shelf 12:     Item 01
 *
 */

OrderRepository orderRepo = new OrderRepository();

// write your code here

Console.WriteLine("Order " + Order[1].OrderLine[1]);


The functions are:

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

namespace WarehouseOptimization
{
    public class Order
    {
        public OrderLine[] orderLines;
        public int id;
        public string customerName;
    }

    public class OrderLine
    {
        public int quantity;
        public string itemName;
    }

    public class OrderRepository
    {
        public Order[] GetYesterdaysOrders()
        {
            Order[] orders = new Order[] {
                                new Order{
                                    id = 1,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 01", quantity = 1},
                                        new OrderLine{ itemName = "Item 02", quantity = 3},
                                        new OrderLine{ itemName = "Item 03", quantity = 25},
                                        new OrderLine{ itemName = "Item 04", quantity = 12},
                                    },
                                },
                                new Order{
                                    id = 2,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 01", quantity = 1},
                                        new OrderLine{ itemName = "Item 08", quantity = 42},
                                        new OrderLine{ itemName = "Item 09", quantity = 13},
                                        new OrderLine{ itemName = "Item 12", quantity = 37},
                                    },
                                },
                                new Order{
                                    id = 3,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 12", quantity = 16},
                                    },
                                },
                                new Order{
                                    id = 4,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 10", quantity = 11},
                                        new OrderLine{ itemName = "Item 11", quantity = 10},
                                    },
                                },
                                new Order{
                                    id = 5,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 06", quantity = 7},
                                        new OrderLine{ itemName = "Item 07", quantity = 2},
                                        new OrderLine{ itemName = "Item 12", quantity = 14},
                                    },
                                },
                                new Order{
                                    id = 6,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 05", quantity = 17},
                                    },
                                },
                                new Order{
                                    id = 7,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 03", quantity = 5},
                                        new OrderLine{ itemName = "Item 07", quantity = 2},
                                    },
                                },
                                new Order{
                                    id = 8,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 02", quantity = 13},
                                        new OrderLine{ itemName = "Item 07", quantity = 7},
                                        new OrderLine{ itemName = "Item 09", quantity = 2},
                                    },
                                },
                                new Order{
                                    id = 9,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 01", quantity = 4},
                                        new OrderLine{ itemName = "Item 06", quantity = 17},
                                        new OrderLine{ itemName = "Item 07", quantity = 3},
                                    },
                                },
                                new Order{
                                    id = 10,
                                    orderLines = new OrderLine[] {
                                        new OrderLine{ itemName = "Item 11", quantity = 12},
                                        new OrderLine{ itemName = "Item 12", quantity = 1},
                                    },
                                },

                             };

            return orders;
        }

    }
}


I used Excel to figure out the proper order for everything:

Quote:
number item
68 12
42 8
30 3
24 6
22 11
17 5
16 2
15 9
14 7
12 4
11 10
6 1


With this, item 12 is most ordered, so it should go on shelf 1, and so on.

My question is how do I sort all this stuff program-wise?

Thanks in advance for your help.
AnswerRe: C# help with classes and a method Pin
Mycroft Holmes17-Sep-18 14:05
professionalMycroft Holmes17-Sep-18 14:05 
Questionsoap web services Pin
Member 1398714017-Sep-18 0:49
Member 1398714017-Sep-18 0:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.