Vaja 01 - Zanke

This commit is contained in:
Gašper Dobrovoljc 2024-03-07 11:44:36 +01:00
parent c893d63b89
commit 063f5feb2d
No known key found for this signature in database
GPG Key ID: 0E7E037018CFA5A5
5 changed files with 332 additions and 1 deletions

2
.idea/.gitignore vendored
View File

@ -6,3 +6,5 @@
# Datasource local storage ignored files # Datasource local storage ignored files
/dataSources/ /dataSources/
/dataSources.local.xml /dataSources.local.xml
# GitHub Copilot persisted chat sessions
/copilot/chatSessions

View File

@ -0,0 +1,3 @@
<component name="ProjectDictionaryState">
<dictionary name="gapi" />
</component>

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

203
src/Vaja01Zanke.java Normal file
View File

@ -0,0 +1,203 @@
public class Vaja01Zanke {
public static void main(String[] args) {
iks(5);
}
static void pravokotnikStevil(int sirina, int visina) {
for (int i = 0; i < visina; i++) {
int stev = i + 1;
while (stev > 9) {
stev -= 10;
}
for (int j = 0; j < sirina; j++) {
System.out.print(stev);
}
System.out.println();
}
}
static void pravokotnikStevil2(int sirina, int visina) {
for (int i = 0; i < visina; i++) {
for (int j = 0; j < sirina; j++) {
int stev = j + 1;
while (stev > 9) {
stev -= 10;
}
System.out.print(stev);
}
System.out.println();
}
}
static void pravokotnik(int odmik, int sirina, int visina) {
for (int i = 0; i < visina; i++) {
for (int j = 0; j < odmik; j++) {
System.out.print(" ");
}
for (int j = 0; j < sirina; j++) {
System.out.print("X");
}
System.out.println();
}
}
static void trikotnikStevil(int visina) {
for (int i = 0; i < visina; i++) {
for (int j = 0; j <= i; j++) {
System.out.print(i + 1);
}
System.out.println();
}
}
static void trikotnikStevilObrnjen(int visina) {
for (int i = visina - 1; i >= 0; i--) {
for (int j = 0; j <= i; j++) {
System.out.print(i + 1);
}
System.out.println();
}
}
static void trikotnikStevilObrnjen2(int visina) {
for (int i = visina - 1; i >= 0; i--) {
for (int j = 0; j <= i; j++) {
System.out.print(j + 1);
}
System.out.println();
}
}
static void trikotnikStevil3(int visina) {
for (int i = 0; i < visina; i++) {
for (int j = 0; j < visina - i - 1; j++) {
System.out.print(" ");
}
for (int j = 0; j < 1 + i * 2; j++) {
System.out.print(j + 1);
}
System.out.println();
}
}
static void trikotnik(int odmik, int visina) {
for (int i = 0; i < visina; i++) {
for (int j = 0; j < visina - i - 1 + odmik; j++) {
System.out.print(" ");
}
for (int j = 0; j < 1 + i * 2; j++) {
System.out.print("*");
}
System.out.println();
}
}
static void trikotnikObrnjen(int odmik, int visina) {
for (int i = visina - 1; i >= 0; i--) {
for (int j = 0; j < visina - i - 1 + odmik; j++) {
System.out.print(" ");
}
for (int j = 0; j < 1 + i * 2; j++) {
System.out.print("*");
}
System.out.println();
}
}
static void romb(int odmik, int velikost) {
trikotnik(odmik, velikost);
trikotnikObrnjen(odmik + 1, velikost - 1);
}
static void smreka(int velikost) {
for (int i = 0; i < velikost; i++) {
trikotnik((velikost - 1) * 2 - (i * 2), (i + 1) * 2);
}
int sirina = velikost;
if (sirina % 2 == 0) {
sirina += 1;
}
pravokotnik(velikost * 2 - 1 - ((sirina - 1) / 2), sirina, 2 * velikost);
}
static void rombA(int odmik, int velikost) {
for (int i = 0; i < velikost; i++) {
for (int j = 0; j < velikost - i - 1 + odmik; j++) {
System.out.print(" ");
}
for (int j = 0; j <= i * 2; j++) {
System.out.print("# ");
}
System.out.println();
}
for (int i = velikost - 2; i >= 0; i--) {
for (int j = 0; j < velikost - i - 1 + odmik; j++) {
System.out.print(" ");
}
for (int j = 0; j <= i * 2; j++) {
System.out.print("# ");
}
System.out.println();
}
}
static void rombPrazen(int odmik, int velikost) {
for (int i = 0; i < 2 * velikost - 1; i++) {
for (int j = 0; j < 2 * velikost - 1; j++) {
if (j >= velikost - i && j <= velikost + i - 2 && j >= i - velikost + 2 && j <= velikost * 2 - i + 1) {
System.out.print(" ");
} else {
System.out.print("# ");
}
}
System.out.println();
}
}
static void iks(int velikost) {
for (int i = 0; i < velikost - 1; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < i * 5; k++) {
System.out.print(" ");
}
for (int k = 0; k < 5; k++) {
System.out.print("X");
}
for (int k = 0; k < ((velikost - 2) * 2 + 1 - 2 * i) * 5; k++) {
System.out.print(" ");
}
for (int k = 0; k < 5; k++) {
System.out.print("X");
}
System.out.println();
}
}
for (int j = 0; j < 3; j++) {
for (int k = 0; k < (velikost - 1) * 5; k++) {
System.out.print(" ");
}
for (int k = 0; k < 5; k++) {
System.out.print("X");
}
System.out.println();
}
for (int i = velikost - 2; i >= 0; i--) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < i * 5; k++) {
System.out.print(" ");
}
for (int k = 0; k < 5; k++) {
System.out.print("X");
}
for (int k = 0; k < ((velikost - 2) * 2 + 1 - 2 * i) * 5; k++) {
System.out.print(" ");
}
for (int k = 0; k < 5; k++) {
System.out.print("X");
}
System.out.println();
}
}
}
}