Skip to content

Commit a595887

Browse files
committed
Add CarProject based on class inheritance.
1 parent e3471c1 commit a595887

File tree

7 files changed

+207
-0
lines changed

7 files changed

+207
-0
lines changed

CarProject/CarProject/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5+
</startup>
6+
</configuration>

CarProject/CarProject/Car.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CarProgram
8+
{
9+
class Car : CarType
10+
{
11+
protected string carColor;
12+
protected int carAxisNumber;
13+
14+
public Car(double power, double capacity, string category, int weight, string color, int axis) : base(power, capacity, category, weight)
15+
{
16+
carColor = color;
17+
carAxisNumber = axis;
18+
}
19+
20+
public void ShowTechnicalData()
21+
{
22+
base.ShowTechnicalData();
23+
Console.WriteLine($"Kolor nadwozia: {carColor}");
24+
Console.WriteLine($"Liczba osi: {carAxisNumber}");
25+
}
26+
}
27+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{CA28C3C0-1EB0-4B88-9624-26983B41052E}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>CarProgram</RootNamespace>
10+
<AssemblyName>CarProgram</AssemblyName>
11+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Car.cs" />
47+
<Compile Include="CarType.cs" />
48+
<Compile Include="Engine.cs" />
49+
<Compile Include="Program.cs" />
50+
<Compile Include="Properties\AssemblyInfo.cs" />
51+
</ItemGroup>
52+
<ItemGroup>
53+
<None Include="App.config" />
54+
</ItemGroup>
55+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
56+
</Project>

CarProject/CarProject/CarType.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CarProgram
8+
{
9+
class CarType : Engine
10+
{
11+
protected string carCategory;
12+
protected int carWeight;
13+
14+
public CarType(double power, double capacity, string category, int weight) : base(power, capacity)
15+
{
16+
carCategory = category;
17+
carWeight = weight;
18+
}
19+
20+
public void ShowTechnicalData()
21+
{
22+
base.ShowTechnicalData();
23+
Console.WriteLine($"Kategoria pojazdu: {carCategory}");
24+
Console.WriteLine($"Waga pojazdu: {carWeight}");
25+
}
26+
27+
}
28+
}
29+
30+

CarProject/CarProject/Engine.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CarProgram
8+
{
9+
class Engine
10+
{
11+
public double enginePower;
12+
public double engineCapacity;
13+
14+
public Engine(double power, double capacity)
15+
{
16+
enginePower = power;
17+
engineCapacity = capacity;
18+
}
19+
20+
public void ShowTechnicalData()
21+
{
22+
Console.WriteLine($"Moc silnika to: {enginePower} kW");
23+
Console.WriteLine($"Pojemność silnika wynosi: {engineCapacity}");
24+
}
25+
26+
}
27+
}

CarProject/CarProject/Program.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+

2+
/* Projekt aplikacji wykorzystującej dziedziczenie klas, tematycznie nawiązujący do parametrów samochodu, przygotowany na zajęcia z Programowania Obiektowego sem. II WSB (2021/2022).
3+
* Autor rozwiązania: Mateusz Stawowski (https://github.com/Mathias007).
4+
* Link do repozytorium zbiorczego: https://github.com/Mathias007/programowanie-obiektowe.
5+
*/
6+
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
13+
namespace CarProgram
14+
{
15+
class Program
16+
{
17+
static void Main(string[] args)
18+
{
19+
Car car = new Car(100, 100, "A", 1000, "red", 4);
20+
car.ShowTechnicalData();
21+
22+
Console.ReadLine();
23+
}
24+
}
25+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CarProgram")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CarProgram")]
13+
[assembly: AssemblyCopyright("Copyright © 2022")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("ca28c3c0-1eb0-4b88-9624-26983b41052e")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)