Just a little homework I have to do. Using OOP approach. Retrieve a data pass it to array then sort it(bubble sort) and then display in the right order like the follow. But im stuck on the bubble sorting part. Can anyone help? following code is right below
Thanks so much for reading! PS. I have also uploaded my code so far same as below as a zip file.

* Lunch Items *
$15.46 bento box a - chicken teriyaki, box combo
$17.26 bento box b – sashimi, box combo

* Dinner Items *
$7.11 roe, 2 rolls
$8.10 tuna roll, 3 rolls
$6.30 vegetable sushi, 6 rolls

Data/meals.csv

lunch,bento box b - sashimi,box combo,$9.59
dinner,vegetable sushi,6 rolls,$3.50
dinner,tuna roll,3 rolls,$4.50
dinner,roe, 2 rolls,$3.95
lunch,bento box a - chicken teriyaki,box combo,$8.59

FileIOManager/FileLocation.cs

using System;
namespace FileIOManager
{
    static class FileLocation
    {
        public const string INPUT_FILE = "../../Data/meals.csv";
    }
}

FileIOManager/FileReader.cs

using System;
using System.IO;

namespace FileIOManager
{
    static public class FileReader
    {
        private static int GetLineCount()
        {
             StreamReader sr = new StreamReader(FileLocation.INPUT_FILE);
             int counter = 0;
             while (!sr.EndOfStream)
             {
                  counter++;
                  sr.ReadLine();
             }
             sr.Close();
             return counter;
         }
     public static string[] ReadLines()
     {
          int totalItems  = GetLineCount();

          string[] itemDetails = new string[totalItems];

          StreamReader sr = new StreamReader(FileLocation.INPUT_FILE);
         
          string itemDetail;
          int counter = 0;
            while (!sr.EndOfStream){
               itemDetail = sr.ReadLine();
                if (itemDetail.Trim() != "")
                    itemDetails[counter++] = itemDetail;
            }

            sr.Close();

            return itemDetails;
        }
    }
}

MealMenu/MenuItem.cs

using System;

namespace MealMenu
{
    class MenuItem
    {
        private string entre = "";
        private string entreType = "";
        private string mealTime = "";
        private string cost;
        private double price;

        public string GetEntre{get{return entre;}}
        public string GetEntreType{get{return entreType;}}
        public string GetMealTime{get{return mealTime;}}
        public double GetPrice{get{return price;}}

        public MenuItem(string csvData)
        {
            string[] items = csvData.Split(',');

            mealTime = items[0];
            entre = items[1];
            entreType = items[2];
            cost = items[3];
            price = Convert.ToDouble(cost.Replace('$', ' ').Trim())*1.8;
        }
     
    }
}

program.cs

using System;
using FileIOManager;
using MealMenu;

namespace Assignment3_Starter
{
    class Program
    {
        string[] mealList;
        
        static void Main(string[] args)
        {
            string[] mealContent = FileReader.ReadLines();
            MenuItem[] mealList = new MenuItem[mealContent.Length];
           // mealList[0] = new MenuItem
            for (int i = 0; i < mealContent.Length; i++)
            {
                mealList[i] = new MenuItem(mealContent[i]);
            }
            Console.ReadLine();
        }
    }
}

I was hoping for a little more help than that >.<

What more do you need? They wrote it out in psuedo code for you, all you have to do is translate it to C#.

You can also search the C# code snippet section. It contains C# code to do a bubble sort.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.