Професионална програма
Loading...
Nvmzax avatar Nvmzax 0 Точки

Compile time error при 08. Vehicle Catalogue от Objects and Classes - Lab

Здравейте!

Бих бил благодарен ако някой ми обясни къде бъркам и защо цялото нещо гърми при проверка в Judge толкова грандиозно, при положние, че на моята машна си се компилира нормално. Не съм използвал нищо странно: System, System.Collections.Generic, System.Linq, System.Text

Error:

Compiled file is missing. Compiler output: ...\tmpCECA.tmp(69,31): error CS1503: Argument 1: cannot convert from 'string' to 'char*'
...\tmpCECA.tmp(57,31): error CS1503: Argument 1: cannot convert from 'string' to 'char*'

 

Също така, ако на някой не му харесва нещо друго, не свързано с текущия ми въпрос, моля пишете.

Ето го и кода

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

namespace Vehicle_Catalog
{
    class Program
    {
        static List<string> Fragmented = new List<string>();

        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            Fragmented = input.Split('/').ToList();
            string command = Fragmented[0];
            Catalog collection = new Catalog();
            while (command != "end")
            {
                if (command == "Car")
                {
                    Car newCar = new Car
                    {
                        Brand = Fragmented[1],
                        Model = Fragmented[2],
                        HorsePower = double.Parse(Fragmented[3])
                    };
                    collection.CarsCatalog.Add(newCar);
                }
                else
                {
                    Truck newTruck = new Truck
                    {
                        Brand = Fragmented[1],
                        Model = Fragmented[2],
                        Weight = double.Parse(Fragmented[3])
                    };
                    collection.TrucksCatalog.Add(newTruck);
                }

                Fragmented = Console.ReadLine().Split('/').ToList();
                command = Fragmented[0];
            }

            Console.Write(collection.ToString());
        }
    }

    public class Truck
    {
        public string Brand { get; set; }
        public string Model { get; set; }
        public double Weight { get; set; }

        public override string ToString()
        {
            return new string($"{Brand}: {Model} - {Weight}kg");
        }
    }

    public class Car
    {
        public string Brand { get; set; }
        public string Model { get; set; }
        public double HorsePower { get; set; }

        public override string ToString()
        {
            return new string($"{Brand}: {Model} - {HorsePower}hp");
        }
    }

    public class Catalog
    {
        public List<Truck> TrucksCatalog { get; set; }
        public List<Car> CarsCatalog { get; set; }

        public Catalog()
        {
            TrucksCatalog = new List<Truck>();
            CarsCatalog = new List<Car>();
        }

        public override string ToString()
        {
            List<Car> orderedCars = CarsCatalog.OrderBy(c => c.Brand).ToList();
            List<Truck> orderedTrucks = TrucksCatalog.OrderBy(t => t.Brand).ToList();
            StringBuilder sb = new StringBuilder();
            if (orderedCars.Count > 0)
            {
                sb.AppendLine("Cars:");
                foreach (Car car in orderedCars)
                {
                    sb.AppendLine(car.ToString());
                }
            }
            if (orderedTrucks.Count > 0)
            {
                sb.AppendLine("Trucks:");
                foreach (Truck truck in orderedTrucks)
                {
                    sb.AppendLine(truck.ToString());
                }
            }

            return sb.ToString();
        }
    }
}

 

Тагове:
0
Programming Fundamentals 26/02/2019 23:45:02 1
Nvmzax:
Question already answered.
ethancarter avatar ethancarter 1 Точки

This instructional exercise shows you how to announce classes, portray traits by means of fields, depict practices by means of techniques, introduce objects through constructors, and start up objects from classes and access their individuals. By : Best Assignment Writing Services

0
1
williamdavid avatar williamdavid 0 Точки

A team comprising of experienced and Professional Essay Writer, researchers, editors, proofreaders and customer support executives make Essays Tigers the only service that students will ever need for all their academic assignments. The icing on the top is that our prices are low as well.

0