Професионална програма
Elena123456 avatar Elena123456 198 Точки

Parking 92/100 - C# Advanced Exam - 28 June 2020


моля за помощ- пети тест гърми и не успявам да разбера къде е проблема.

клас Car - https://pastebin.com/ff155QRC

клас Parking - https://pastebin.com/Pm7LF0mu

Judge- https://judge.softuni.bg/Contests/Practice/Index/2444#2




Download the skeleton provided in Judge. Do not change the StartUp class or its namespace.

Problem description

Your task is to create a repository, which stores items by creating the classes described below.

First, write a C# class Car with the following properties:

  • Manufacturer: string
  • Model: string
  • Year: int

The class constructor should receive manufacturer, model and year and override the ToString() method in the following format:

"{manufacturer} {model} ({year})"

Next, write a C# class Parking that has data (a collection, which stores the entity Car). All entities inside the repository have the same properties. Also, the Parking class should have those properties:

  • Type: string
  • Capacity: int

The class constructor should receive type and capacity, also it should initialize the data with a new instance of the collection. Implement the following features:

  • Field datacollection that holds added cars
  • Method Add(Car car) – adds an entity to the data if there is an empty cell for the car.
  • Method Remove(string manufacturer, string model) – removes the car by given manufacturer and model, if such exists, and returns bool.
  • Method GetLatestCar() – returns the latest car (by year) or null if have no cars.
  • Method GetCar(string manufacturer, string model) – returns the car with the given manufacturer and model or null if there is no such car.
  • Getter Count – returns the number of cars.
  • returns a string in the following format:
    • "The cars are parked in {parking type}:


  • The combinations of manufacturers and models will be always unique.
  • The year of the cars will always be positive.
  • There won't be cars with the same years.


This is an example how the Parking class is intended to be used.

Sample code usage

// Initialize the repository

Parking parking = new Parking("Underground parking garage", 5);


// Initialize entity

Car volvo = new Car("Volvo", "XC70", 2010);


// Print Car

Console.WriteLine(volvo); // Volvo XC70 (2010)


// Add Car



// Remove Car

Console.WriteLine(parking.Remove("Volvo", "XC90")); // False

Console.WriteLine(parking.Remove("Volvo", "XC70")); // True


Car peugeot = new Car("Peugeot", "307", 2011);

Car audi = new Car("Audi", "S4", 2005);





// Get Latest Car

Car latestCar = parking.GetLatestCar();

Console.WriteLine(latestCar); // Peugeot 307 (2011)


// Get Car

Car audiS4 = parking.GetCar("Audi", "S4");

Console.WriteLine(audiS4); // Audi S4 (2005)


// Count

Console.WriteLine(parking.Count); // 2


// Get Statistics


// The cars are parked in Underground parking garage:

// Peugeot 307(2011)

// Audi S4(2005)


Zip all the files in the project folder except bin and obj folders.


C# Advanced
Axiomatik avatar Axiomatik 1135 Точки
Best Answer


Usually, when judge only gives 91% or 92%, this means that something is wrong with the final output method that overwrites ToString() and summarizes all data in the given class. Try to change:

        public string GetStatistics()
            var sb = new StringBuilder();
            string information = $"The cars are parked in {this.Type} parking garage.";
            foreach (var car in this.data)
            return sb.ToString().TrimEnd();


        public string GetStatistics()
            StringBuilder sb = new StringBuilder();
            sb.AppendLine($"The cars are parked in {this.Type}:");
            foreach (var car in this.data)

            return sb.ToString().TrimEnd();


Elena123456 avatar Elena123456 198 Точки

Hi @ Axiomatik ,

thanks a lot for your comment and for every other. If you didn't help me, I couldn't do anything in programming exercises, especially in OOP.

Thanks a lot and to @MartinBG , who helped me in the basic module, show me how to work with multidimensional arrays and streams. 

Thanks and to @ nickwork , who helped me a lot in basic and fundamental.

I couldn't forget anyone of you and your helping ,and I will be forever gratefull!

Take care and I wish you all the best!

By the way this is my github https://github.com/elipopovadev and if any of you have github I would follow you.