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

Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You will be simulating an ATM machine as much as possible Pretend you have an initial deposit of 1000.00. You will Prompt the user with a Main menu: Enter 1 to deposit Enter 2 to Withdraw Enter 3 to Print Balance Enter 4 to quit When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount....
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...
1-Create a new Visual C# Console App (.NET Framework). Name the solution "GPA Calculation". 2-Zip and...
1-Create a new Visual C# Console App (.NET Framework). Name the solution "GPA Calculation". 2-Zip and Submit your entire project with the solution file GPA Ask the user to input their grade percentage (e.g. the use will enter 98 if they had an overall grade of 98% in their course) for their Accounting, Marketing, Economics and MIS courses. Assume each course is worth 3 credit hours. Once you have all of their grades output what letter grade they earned for...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3<FirstName><LastName>P2. For example, a student with first name John and Last name Smith would name the project A1JohnSmithP2. Write a C# (console) program to calculate the number of shipping labels that can be printed on a sheet of paper. This program will use a menu...
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 C# console application (do not create a .NET CORE project) and name the project....
Create a C# console application (do not create a .NET CORE project) and name the project. Generate two random integers, each between 1 and 50, that you will be adding together to test the user's ability to perform the addition operator. Display the numbers in the console, such as:             7 + 22 = ? Once the user provides their answer, check to see if it is correct and if not, tell them sorry, please try again. If their answer...
Create a C# console application (do not create a .NET CORE project) and name the project...
Create a C# console application (do not create a .NET CORE project) and name the project TuitionIncrease. The college charges a full-time student $12,000 in tuition per semester. It has been announced that there will be a tuition increase by 5% each year for the next 7 years. Your application should display the projected semester tuition amount for the next 7 years in the console window in the following format:             The tuition after year 1 will be $12,600. Note:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT