Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Data
Customer Information
•	Forename
•	Surname
•	Date of Birth
Vehicle Information
•	Manufacturer
•	Model
•	Registration number
•	Registration date
•	Engine size (in cc)
•	Owner
•	InteriorColour (Car only)
•	Has Helmet Storage (Motorcycle only)
Required Relationships
•	Customers can have 1 to many vehicles.
•	Vehicle must have exactly one owner.
•	Vehicle type cannot be changed once it is created.
Reports
•	We will require reports to be designed to contain:
o	All known customers and any vehicles they own.
o	All customers between the age of 20 and 30.
o	All Vehicles registered before 1st January 2010.
o	All Vehicles with an engine size over 1100.
Expected demonstrable skills
•	Good understanding of C#.
•	Good understanding of Object Orientated (OO) principles.
•	Good understanding of relational data principles.
•	Reusable code – low coupling, high cohesion


What I have tried:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Graduate_Test_Brief
{
    class Program
    {

        static void Main(string[] args)
        {
            string sChoice;
            int iChoice;
            do
            {
                Console.WriteLine("WELCOME TO CRM...");
                Console.WriteLine("PLEASE CHOOSE A OPTION FROM BELOW:");
                Console.WriteLine("1. REPORT FOR ALL KNOWN CUSTOMERS AND ANY VEHICLES THEY OWN.");
                Console.WriteLine("2. REPORT FOR ALL CUSTOMERS BETWEEN THE AGE OF 20 AND 30.");
                Console.WriteLine("3. REPORT FOR ALL VEHICLES REGISTERED BEFORE 1ST JANUARY 2010.");
                Console.WriteLine("4. REPORT FOR ALL VEHICLES WITH AN ENGINE SIZE OVER 1100.");
                Console.Write("PLEASE ENTER YOUR CHOICE HERE: ");
                sChoice = Console.ReadLine();
                iChoice = Convert.ToInt32(sChoice);

                switch (iChoice)
                {
                    case 1:
                        Report1(@"..\..\Assets\Customer Information.csv");
                        break;

                    case 2:
                        Report2(20, 30, @"..\..\Assets\Customer Information.csv", 3);
                        break;

                    case 3:
                        Report3(2010, @"..\..\Assets\Customer Information.csv", 9);
                        break;

                    case 4:
                        Report4(1100, @"..\..\Assets\Customer Information.csv", 8);
                        break;
                    default:
                        Console.Read();
                        break;


                }

            } while (true);

        }


        public static void Report1(string filePath)
        {
            string[] reportNotFound = { "Report Not Found" };

            List<string[]> list1 = new List<string[]>();
            try
            {
                string[] lines = File.ReadAllLines(filePath);

                for (int i = 1; i <= lines.Length; i++)
                {
                    string[] fields = lines[i].Split(',');

                    // string vs = fields[coloumn];
                    // int vs1 = Int32.Parse(vs);
                    //if (vs1 >= data1)
                    //{                
                    list1.Add(fields);
                    //}
                }

                // return list1;

            }
            catch (Exception e)
            {
                foreach (var list in list1)
                {

                    for (int i = 0; i < list.Length; i++)
                    {

                        Console.Write("     "+list[i]);

                    }
                    Console.WriteLine();
                }
            }
        }


        private static void Report2(int minAge, int maxAge, string filePath, int coloumn)
        {
            string[] reportNotFound = { "Report Not Found" };

            List<string[]> list1 = new List<string[]>();
            try
            {
                string[] lines = File.ReadAllLines(filePath);

                for (int i = 1; i <= lines.Length; i++)
                {
                    string[] fields = lines[i].Split(',');

                    string vs = fields[coloumn];
                    DateTime birthDate = DateTime.Parse(vs);
                    DateTime currentDate = DateTime.Now;

                    int age = currentDate.Year - birthDate.Year;

                    if (birthDate > currentDate.AddYears(-age))
                    {
                        age--;
                    }

                    if (age > minAge && age < maxAge)
                    {
                        list1.Add(fields);
                    }
                }

                // return list1;

            }
            catch (Exception e)
            {
                foreach (var list in list1)
                {

                    for (int i = 0; i < 1; i++)
                    {

                        Console.Write(list[0] + "     " + list[1] + "     " + list[2]);

                    }
                    Console.WriteLine();
                }
            }
        }


        private static void Report3(int Year, string filePath, int coloumn)
        {
            string[] reportNotFound = { "Report Not Found" };

            List<string[]> list1 = new List<string[]>();
            try
            {
                string[] lines = File.ReadAllLines(filePath);

                for (int i = 1; i <= lines.Length; i++)
                {
                    string[] fields = lines[i].Split(',');

                    string vs = fields[coloumn];
                    DateTime regDate = DateTime.Parse(vs);
                    //int regYear = Convert.ToInt32(regDate.Year);
                    if (regDate.Year < Year)
                    {
                        list1.Add(fields);
                    }
                }

                // return list1;

            }
            catch (Exception e)
            {
                foreach (var list in list1)
                {

                    for (int i = 0; i < 1; i++)
                    {

                        Console.Write(list[4] + "     " + list[5] + "     " + list[6] + "     " + list[7] + "     " + list[8] + "     " + list[9] + "     " + list[10] + "     " + list[11] + "     " + list[12]);

                    }
                    Console.WriteLine();
                }
            }
        }

        private static void Report4(int engSize, string filePath, int coloumn)
        {
            string[] reportNotFound = { "Report Not Found" };

            List<string[]> list1 = new List<string[]>();
            try
            {
                string[] lines = File.ReadAllLines(filePath);

                for (int i = 1; i <= lines.Length; i++)
                {
                    string[] fields = lines[i].Split(',');

                    string vs = fields[coloumn];
                    int engineSize = Int32.Parse(vs);
                    //int regYear = Convert.ToInt32(regDate.Year);
                    if (engineSize > engSize)
                    {
                        list1.Add(fields);
                    }
                }

                // return list1;

            }
            catch (Exception e)
            {
                foreach (var list in list1)
                {

                    for (int i = 0; i < 1; i++)
                    {

                        Console.Write(list[4] + "     " + list[5] + "     " + list[6] + "     " + list[7] + "     " + list[8] + "     " + list[9] + "     " + list[10] + "     " + list[11] + "     " + list[12]);

                    }
                    Console.WriteLine();

                }
            }
        }
    }
}
Posted
Updated 15-Aug-19 13:30pm

When you posted this last time, I told you to read it again, and pay attention to the "Expected demonstrable skills" section.

And you have totally ignored it, and written a monolithic procedural app with not a trace of the required skills.
Is there any point in asking for comments if you ignore what we tell you?
 
Share this answer
 
Comments
Member 14559183 15-Aug-19 17:37pm    
what i have done is in a normal way and i have try to do oop stuff but i cant think much about that if i try to do that then it will mess up the program i have considered ur comment in last one. what are the way to demonstrate that skills
OriginalGriff 15-Aug-19 18:01pm    
The only way - seriously, *the only way* - to demonstrate the skills they want to see is to do exactly what they ask for!

Which mean - since they absolutely do specify it - an OOPs solution.
Anything else is just wasting your time, and theirs. So it doesn't matter what it "messes up", unless you scrap that lot and start again from an OOPs POV, all you are doing is pleasing yourself. You will not get any further in the interview process with your current approach.
From your comments on your question on this topic 1 day ago:
Requirements overview we require you to write a “C# console application” for a basic customer relationship manager (CRM) application. Need to fetch data from CSV file[^]

I think you are well beyond this point:
Important Considerations before you begin:
We expect that this test will last around 2 – 3 hours but you can take longer or shorter if you wish. If you run out of time then please feel free to include notes that detail what you would do next, or what you would have liked to have done given more time.
 
Share this answer
 
I wouldn't even accept the code you wrote as the answer to homework assignment.

You've got nothing but report methods that all do pretty much the same thing. The method reads the file, parses it, does some manipulation and spits out a report.

Just the fact that you're you are COPYING AND PASTING THE SAME CODE into multiple methods disqualifies you for any job.

Give it up. You're not getting whatever job you're applying for.

Instead, you've got a LOT of learning to do.
 
Share this answer
 
Quote:
Please check my code does that meet the requirements. It is a CRM.

You should be able to answer yourself.
Quote:
Good understanding of Object Orientated (OO) principles.

All your OO code is this line:
C#
class Program

Do you think it is enough ?
Quote:
Good understanding of relational data principles.

What magic are you using to show an understanding of 'relational data' without anything relational ?

You coding style is particularly poor
C++
foreach (var list in list1)
{

    for (int i = 0; i < 1; i++) // this loop loops exactly 1 time
    { // why do you have a loop at all ?

        Console.Write(list[4] + "     " + list[5] + "     " + list[6] + "     " + list[7] + "     " + list[8] + "     " + list[9] + "     " + list[10] + "     " + list[11] + "     " + list[12]);

    }
    Console.WriteLine();

}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900