Question

In: Computer Science

1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname. 2....

1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname.

2. Implement a vehicle rental management system which is capable of doing the following: • View all, available and reserved vehicles. • Reserve vehicle or cancel a reservation.

3. The application must be menu-based app: 1 - View all vehicles 2 - View available vehicles 3 - View reserved vehicles 4 - Reserve a vehicle 5 - Cancel reservation 6 - Exit

4. NOTE: At no point should the application save any information to disk. All information is stored and managed in memory using a collection. The use of collections and the object-oriented design of the solution are an important part of the evaluation of your submission.

5. The rental company has inventory of cars and motorcycles.

• There are three categories of cars: Hatchback, Sedan, SUV

• And three categories of motorcycles: Cruiser, Sports, Dirt

• There are two types of cars: oStandard – a normal car oExotic – expensive sports car

• And two types of motorcycles: oBike – a standard two-wheeler motorcycle oTrike – a three-wheeler motorcycle

6. Create classes to represent Car and Motorcycle.

7. These classes must inherit from parent class Vehicle.

8. These vehicles must have following fields: ID, Name, Rental Price, Category, Type, IsReserved

9. Use your Java and object-oriented programming knowledge to create this hierarchy.

10. The application should keep track of available and reserved vehicles using the most appropriate generic collection.

11. Use LINQ to display all, available and reserved vehicles.

12. Your knowledge of object-oriented programming will play an important role in evaluation. • You will get higher grades if: Proper use of inheritance Interface is user-friendly

Used LINQ to display vehicles

App menu runs smoothly without crashing

Otherwise, there will be grade deductions.

13. The menu should run continuously until the user quits the application.

Solutions

Expert Solution

please find below code

main program

using System;
using System.Collections.Generic;
using System.Linq;

namespace A1fnamelname
{
    class Program
    {
        static void Main(string[] args)
        {
            int ch;
            var Car = new List<Car>();
            var Moto = new List<Motorcycle>();
            Car.Add(new Car("Name1", 1, 1000, "Hatchback", "oStandard"));
            Car.Add(new Car("Name2", 2, 2000, "Sedan", "oStandard"));
            Car.Add(new Car("Name3", 3, 3000, "SUV", "oExotic"));

            Moto.Add(new Motorcycle("MName1", 1, 1000, "Cruiser", "oBike"));
            Moto.Add(new Motorcycle("MName2", 2, 2000, "Sports", "oTrike "));
            Moto.Add(new Motorcycle("MName3", 3, 3000, "Dirt", "oBike"));
            do
            {
                menu();
                ch = Convert.ToInt32(Console.ReadLine());
                switch(ch)
                {
                    case 1:
                        Console.WriteLine("Car");
                        var avlistt = (from s in Car                                     
                                      select s).ToList();
                        foreach (var cars in avlistt)
                            Console.WriteLine(cars);
                        Console.WriteLine("Motor Cycle");
                        var avlist = (from s in Moto                                    
                                      select s).ToList();
                        foreach (var cars in avlist)
                        
                            Console.WriteLine(cars);
                        
                        break;
                    case 2:
                        Console.WriteLine("Car");
                        avlistt = (from s in Car
                                   where s.IsReserve() == false
                                   select s).ToList();
                        foreach (var cars in avlistt)
                        {
                            Console.WriteLine(cars);
                        }
                        Console.WriteLine("Motor Cycle");
                        avlist = (from s in Moto
                                  where s.IsReserve() == false
                                  select s).ToList();
                        foreach (var cars in avlist)
                        {
                            Console.WriteLine(cars);
                        }
                        break;
                    case 3:
                        Console.WriteLine("Car");
                        avlistt = (from s in Car
                                      where s.IsReserve() == true
                                      select s).ToList();
                        foreach (var cars in avlistt)
                        {
                            Console.WriteLine(cars);
                        }
                        Console.WriteLine("Motor Cycle");
                        avlist = (from s in Moto
                                      where s.IsReserve() == true
                                      select s).ToList();
                        foreach (var cars in avlist)
                        {
                            Console.WriteLine(cars);
                        }

                        break;
                    case 4:
                        Console.WriteLine("Reserve vehicle");
                        Console.WriteLine("Please select Vehicle \n 1. Car \n2. MotoCycle");
                        int vc = Convert.ToInt32(Console.ReadLine());
                        Console.Write("Available Vehicles are: ");
                        if (vc==1)
                        {
                             avlistt = (from s in Car
                                         where s.IsReserve() == false
                                         select s).ToList();
                            foreach(var cars in avlistt)
                            {
                                Console.WriteLine(cars);
                            }
                            Console.WriteLine("Please Enter ID");
                            int id = Convert.ToInt32(Console.ReadLine());
                           
                            foreach (var cars in avlistt)
                            {
                                if (cars.GetID() == id)
                                {
                                    cars.setReserve();
                                }
                           
                            }
                            
                        }
                        else
                        {
                             avlist = (from s in Moto
                                         where s.IsReserve() == false
                                         select s).ToList();
                            foreach (var cars in avlist)
                            {
                                Console.WriteLine(cars);
                            }
                            Console.WriteLine("Please Enter ID");
                            int id = Convert.ToInt32(Console.ReadLine());
                            foreach (var cars in avlist)
                            {
                                if (cars.GetID() == id)
                                {
                                    cars.setReserve();
                                }

                            }
                        }
                        
                        
                        break;
                    case 5:
                        Console.WriteLine("Please select Vehicle \n 1. Car \n2. MotoCycle");
                         vc = Convert.ToInt32(Console.ReadLine());
                                               
                        if (vc == 1)
                        {
                            avlistt = (from s in Car
                                       where s.IsReserve() == false
                                       select s).ToList();                            
                            Console.WriteLine("Please Enter ID");
                            int id = Convert.ToInt32(Console.ReadLine());

                            foreach (var cars in avlistt)
                            {
                                if (cars.GetID() == id)
                                {
                                    cars.CancelReserve();
                                }

                            }

                        }
                        else
                        {
                            avlist = (from s in Moto
                                      where s.IsReserve() == false
                                      select s).ToList();                           
                            Console.WriteLine("Please Enter ID");
                            int id = Convert.ToInt32(Console.ReadLine());
                            foreach (var cars in avlist)
                            {
                                if (cars.GetID() == id)
                                {
                                    cars.CancelReserve();
                                }

                            }
                        }
                        break;

                }
                
            } while (ch != 6);
        }
       
        public static void menu()
        {
            Console.WriteLine("Enter your option");
            Console.WriteLine("1: View all vehicle");
            Console.WriteLine("2: View available vehicles");
            Console.WriteLine("3: View reserved vehicles");
            Console.WriteLine("4: Reserve a vehicle");
            Console.WriteLine("5: Cancel reservation ");
            Console.WriteLine("6: Exit");          
        }
    }

}

car class

using System;
using System.Collections.Generic;
using System.Text;

namespace A1fnamelname
{
    class Car : Vehicle
    {
      
        
        public Car(string Name, int ID,  double Price, string Category, string Type) : base(Name, Price, Category, Type,ID)
        {
            

        }
      
    }
}

Motorcycle class

using System;
using System.Collections.Generic;
using System.Text;

namespace A1fnamelname
{
    public class Motorcycle : Vehicle
    {
       
        
        public Motorcycle(string Name, int ID, double Price, string Category, string Type):base(Name, Price, Category, Type,ID)
        {         
         

        }

    }
}

Vehicle class

using System;
using System.Collections.Generic;
using System.Text;

namespace A1fnamelname
{
   public class Vehicle
    {      
        string Name;
        int ID;
        double Price;
        string Category;
        string Type;
        bool IsReserved;
        public Vehicle(string Name, double Price,string Category ,string Type,int ID)
        {
            this.Name = Name;
            this.ID = ID;
            this.Price = Price;
            this.Category = Category;
            this.Type = Type;
            this.IsReserved = false;
        }
        public void setReserve()
        {
            this.IsReserved = true;
        }
        public void CancelReserve()
        {
            this.IsReserved = false;
        }
        public bool IsReserve()
        {
            return IsReserved;
        }
        public int GetID()
        {
            return this.ID;
        }
        override public string ToString()
        {
            string outp = String.Empty;
            outp += "ID: "+ID+"\t"+"Name :"+ Name + "\t" + "Rental price: " + Price +"\t"+ "Category: " + Category+"\t" + "Type: " + Type;
            return outp;

        }
    }
}

output


Related Solutions

Create a C# .NET Core Console project in Visual Studio. (This is the same kind of...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of project we have been doing all semester.) Do all of the following in the Program class. You do not need to add any other classes to this project. 2. If it exists, remove the Console.WriteLine(“Hello World!”); line that Visual Studio created in the Program class. 3. At the very top of the Program.cs page you should see using System; On the empty line below...
Create a Visual Studio console project named exercise101. The main() function should prompt for the name...
Create a Visual Studio console project named exercise101. The main() function should prompt for the name of a text file located in the same directory as exercise101.cpp, and search for a word in the text file as follows: Enter text file name: Enter search word: The program should print the number of occurrences of the word in the file: occurrences of were found in If the file could not be opened then display: File not found Use Stream file I/O...
Start by creating a new Visual Studio solution, but chose a “class library .Net Core” as...
Start by creating a new Visual Studio solution, but chose a “class library .Net Core” as the project type. It will create a file and a class definition in that file.  Rename the file to be ToDo.cs  and accept the suggestion which will also rename that class to be Class Todo { } In that class, create             - a string property called Title             - an int property called  Priority             - a bool property called Complete Also, define one Constructor that takes in one...
Write a C program The Visual Studio project itself must make its output to the Console...
Write a C program The Visual Studio project itself must make its output to the Console (i.e. the Command Prompt using printf) and it must exhibit the following features as a minimum: 3%: Looping Menu with 3 main actions: View Cars, Sell Car, View Sales Note: A Car is defined by its price and model 3%: Must contain at least three arrays to record sales figures (maximum of 10 Car models) Two for recording the price and model of one...
1. Start a new Visual Studio project and name it GradeAppa. Make sure your project...
1. Start a new Visual Studio project and name it GradeAppa. Make sure your project is a web projectb. Make sure it is using C#2. Add a new folder and name it Grades_Logic3. Inside this new folder create a new web form called “Grades”4. Add a label to hold text “Enter Grade”5. Add a text field in front of the label to receive the grade6. Add another label in a new line to display the text “Participation”7. Place a drop-down...
Create a Visual Studio console project (c++) containing a main() program that declares a const int...
Create a Visual Studio console project (c++) containing a main() program that declares a const int NUM_VALUES denoting the array size. Then declare an int array with NUM_VALUES entries. Using a for loop, prompt for the values that are stored in the array as follows: "Enter NUM_VALUES integers separated by blanks:" , where NUM_VALUES is replaced with the array size. Then use another for loop to print the array entries in reverse order separated by blanks on a single line...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in Assignment 04.1 to C++ code inside the main() function. Your program should prompt for a single 9-digit routing number without spaces between digits as follows: Enter a 9-digit routing number without any spaces: The program should output one of: Routing number is valid Routing number is invalid A C++ loop and integer array could be used to extract the routing number's 9 digits. However...
ceate a Visual Studio console project named exercise093. In the exercise093.cpp file first define a function...
ceate a Visual Studio console project named exercise093. In the exercise093.cpp file first define a function void lowerToUpper(std::string & sentence) that iterates over all characters in the sentence argument. Any lowercase letter should be converted to uppercase. This can be done by including and testing each character in sentence with the islower() function. If islower(sentence[i]) returns true then sentence[i] should be replaced with toupper(sentence[i]). The main() function should assign "Hello how are you doing?" to sentence, call lowerToUpper(sentence), and use...
Create a Visual Studio console project named exercise093. In the exercise093.cpp file first define a function...
Create a Visual Studio console project named exercise093. In the exercise093.cpp file first define a function void lowerToUpper(std::string & sentence) that iterates over all characters in the sentence argument. Any lowercase letter should be converted to uppercase. This can be done by including <cctype> and testing each character in sentence with the islower() function. If islower(sentence[i]) returns true then sentence[i] should be replaced with toupper(sentence[i]). The main() function should assign "Hello how are you doing?" to sentence, call lowerToUpper(sentence), and...
Make a Console application Language should be Visual Basic In this assignment, you will be calculating...
Make a Console application Language should be Visual Basic In this assignment, you will be calculating the two parts for each month. you calculate the interest to pay each month and principal you pay every month. The interest you pay every month = loan * monthlyInterest The principal you pay every month = monthlyMortgage -  interest you pay every month ' what is my remaining loan loan = loan - principal you pay every month Problem 1 : Using While Loop,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT