-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28b8975
commit 03acb6f
Showing
2 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
188 changes: 188 additions & 0 deletions
188
...tent/docs/products/splashkit/SplashKit Tutorials/Documentation/4-adding-oop.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
--- | ||
title: Guide to adding OOP to SplashKit tutorials | ||
sidebar: | ||
label: 4. Adding OOP to Guides | ||
order: 4 | ||
--- | ||
|
||
import { Tabs, TabItem } from "@astrojs/starlight/components"; | ||
|
||
## Adding OOP and Top Level C# to Splashkit Tutorials | ||
|
||
One of the current goals of the SplashKit team is to enhance the tutorials by including both top-level statement and object-oriented (OOP) versions of C# programs. This guide outlines how to effectively integrate OOP into the existing tutorials, providing both options for users to choose from. | ||
|
||
### The Full Code Block Structure | ||
|
||
The full code block structure for C++, C# in top level and OOP, and Python is as follows: | ||
|
||
````md | ||
<Tabs> | ||
<TabItem label="C++"> | ||
|
||
```cpp | ||
|
||
Add C++ code here | ||
|
||
``` | ||
|
||
</TabItem> | ||
<Tabs syncKey="csharp-style"> | ||
<TabItem label="Top-level Statements"> | ||
|
||
```csharp | ||
|
||
Add top-level statement version of C# code here | ||
|
||
``` | ||
|
||
</TabItem> | ||
<TabItem label="Object-Oriented"> | ||
|
||
```csharp | ||
|
||
Add OOP version of C# code here | ||
|
||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
<TabItem label="Python"> | ||
|
||
```python | ||
|
||
Add Python code here | ||
|
||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
```` | ||
|
||
This is the new standard structure for all Splashkit tutorials. The C# code block has been replaced with a tabs component that contains two tabs, one for top-level statements and one for object-oriented programming. The C# code block has been replaced with a tabs component that contains two tabs, one for top-level statements and one for object-oriented programming. | ||
|
||
### Adding OOP to the Splashkit tutorials | ||
|
||
If you are adding OOP to the Splashkit tutorials, you will need to replace the C# section with the following code block in order to have both top-level statements and object-oriented programming options: | ||
|
||
````md | ||
<Tabs syncKey="csharp-style"> | ||
<TabItem label="Top-level Statements"> | ||
|
||
```csharp | ||
|
||
Add top-level statement version of C# code here | ||
|
||
``` | ||
|
||
</TabItem> | ||
<TabItem label="Object-Oriented"> | ||
|
||
```csharp | ||
|
||
Add OOP version of C# code here | ||
|
||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
```` | ||
|
||
## Example | ||
|
||
Once done, the view of the code blocks will remain the same on the Splashkit site. However, once clicking on the C# tab, the user will be able to see both the top-level statements and object-oriented programming versions of the code. | ||
|
||
<Tabs syncKey="code-language"> | ||
<TabItem label="C++"> | ||
|
||
```cpp | ||
#include "splashkit.h" | ||
|
||
int main() | ||
{ | ||
string name; // declare a variable to store the name | ||
string quest; // and another to store a quest | ||
|
||
write("What is your name: "); // prompt the user for input | ||
name = read_line(); // read user input | ||
|
||
// read in another value | ||
write("And what is your quest? "); | ||
quest = read_line(); | ||
|
||
write_line(name + "'s quest is: " + quest); // output quest to the terminal | ||
|
||
return 0; | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem label="C#"> | ||
|
||
<Tabs syncKey="csharp-style"> | ||
<TabItem label="Top-level Statements"> | ||
|
||
```csharp | ||
using static SplashKitSDK.SplashKit; | ||
|
||
string name; // declare a variable to store the name | ||
string quest; // and another to store a quest | ||
Write("What is your name: "); // prompt the user for input | ||
name = ReadLine(); // read user input | ||
// Read in another value | ||
Write("And what is your quest? "); | ||
quest = ReadLine(); | ||
|
||
WriteLine(name + "'s quest is: " + quest); // output quest to the terminal | ||
``` | ||
|
||
</TabItem> | ||
<TabItem label="Object-Oriented"> | ||
|
||
```csharp | ||
using SplashKitSDK; | ||
|
||
namespace ReadingText | ||
{ | ||
public class Program | ||
{ | ||
public static void Main() | ||
{ | ||
string name; // declare a variable to store the name | ||
string quest; // and another to store a quest | ||
SplashKit.Write("What is your name: "); // prompt the user for input | ||
name = SplashKit.ReadLine(); // read user input | ||
// Read in another value | ||
SplashKit.Write("And what is your quest? "); | ||
quest = SplashKit.ReadLine(); | ||
|
||
SplashKit.WriteLine(name + "'s quest is: " + quest); // output quest to the terminal | ||
} | ||
} | ||
} | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
</TabItem> | ||
<TabItem label="Python"> | ||
|
||
```python | ||
from splashkit import * | ||
|
||
write("What is your name: ") # prompt the user for input | ||
name = read_line() # read user input and store in a variable | ||
|
||
# Read in another value | ||
write("And what is your quest? ") | ||
quest = read_line() | ||
|
||
write_line(name + "'s quest is: " + quest) | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> |