Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lesson1.maraphon/Animal.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ public boolean isDistance() {
public void info() {
System.out.println(type + " " +name+ " "+ onDistance);
}

}
22 changes: 17 additions & 5 deletions lesson1.maraphon/Cource.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

public class Cource {

Obstracle[] c = {new Cross(80),new Wall(5),new Water(3)};
private Obstracle[] c = {new Cross(80),new Wall(5),new Water(3)};

public void doIt(Team team){
System.out.println("Команда: " + team);
for (Competitor competitor : team.getCompetitors()) {
for (Obstracle obstracle : c) {
if (competitor.isDistance() == true) {
System.out.println(team.getCompetitors() + " успешно перепрыгнул");
obstracle.doIt(competitor);
} else {
System.out.println(team.getCompetitors() + " не получилось");
}
}
}

public void doIt(){
Cross(80);
Wall(5);
Water(3);
}


}

4 changes: 4 additions & 0 deletions lesson1.maraphon/Human.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ public boolean isDistance() {
public void info() {
System.out.println(name + " " + active);
}

public String getName() {
return name;
}
}
4 changes: 3 additions & 1 deletion lesson1.maraphon/MainCross.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ public class MainCross {
public static void main(String[] args) {

Cource c = new Cource ();
Team comp = new Team ();
Team comp = new Team ("1" , new Human("Bob"), new Cat("Vaska"), new Dog("Tuzik") );

c.doIt(comp);



/* Competitor[] competitors = {new Human("Bob"), new Cat("Vaska"),new Dog("Tuzik")};
Obstracle[] obstracles = {new Cross(80),new Wall(5),new Water(3)};
for(Competitor c: competitors){
Expand Down
14 changes: 13 additions & 1 deletion lesson1.maraphon/Team.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
package lesson1.maraphon;

public class Team {
Competitor[] comp = {new Human("Bob"), new Cat("Vaska"),new Dog("Tuzik")};

private String name;
private Competitor[] competitors;

public Team (String name, Competitor... competitors){
this.name = name;
this.competitors = competitors;
}


public Competitor[] getCompetitors() {
return competitors;
}


}
Expand Down
27 changes: 27 additions & 0 deletions lesson2/arrayExceprion/main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package lesson2.arrayExceprion;

import java.lang.reflect.Array;
import java.util.Arrays;

public class main {
public static void main(String[] args) {

String[] weekDays = {"1", "2", "3" , "4"};
Arr(weekDays);
}
//int i=Integer.parseInt(s);
public static void Arr(String[] a){
int[] pars = new int[a.length];
int sum;
for (int i = 0; i < a.length; i++) {
pars[i] = Integer.parseInt(a[i]);
System.out.println(pars[i]);
}
sum = pars[0]+pars[1]+pars[2]+pars[3];
System.out.println(sum);
}


}


31 changes: 31 additions & 0 deletions lesson3/maps/PhoneBook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package lesson3.maps;

import java.util.*;

public class PhoneBook {
private Map<String, String> pb;

public PhoneBook() {
pb = new TreeMap<>();
}

public void add(String name, String phone) {
pb.put(name, phone);
}

List<String> get(String name) {
List<String> list = new ArrayList<>();
for (Map.Entry<String, String> entry : pb.entrySet())
if (name.equals(entry.getKey()))
list.add(entry.getKey()+ " " + entry.getValue());

return list;
}

@Override
public String toString() {
return pb.toString();
}


}
54 changes: 54 additions & 0 deletions lesson3/maps/main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Java. level 2. Lesson 3. Example of homework
* autor Rudenko Alexander
* version date 07/01/2019
*
*/
package lesson3.maps;

import java.util.*;

public class main {
public static void main(String[] args) {
// 1 Часть задания ----------------------------------
ArrayList<String> al = new ArrayList<>();
al.add("Яблоко"); al.add("Банан"); al.add("Апельсин"); al.add("Мандарин"); al.add("Яблоко"); al.add("Груша"); al.add("Ананас"); al.add("Банан"); al.add("Киви"); al.add("Абрикос");
System.out.println(al);
System.out.println("Всего элементов = " + al.size());

Set unic = new HashSet(al);
System.out.println(unic);
System.out.println("Всего уникальных элементов = "+ unic.size());

System.out.println("Подсчет уникальных элементов:");
HashMap<String, Integer> wordToCount = new HashMap<>();
for (String word : al)
{
if (!wordToCount.containsKey(word))
{
wordToCount.put(word, 0);
}
wordToCount.put(word, wordToCount.get(word) + 1);
}
for (String word : wordToCount.keySet())
{
System.out.println(word + " " + wordToCount.get(word));
}
//------------------------------------------------------

// 2 Часть задания ----------
System.out.println("\n" + "Записная книга:");

PhoneBook phoneBook = new PhoneBook();
phoneBook.add("Саня", "863 233 3301");
phoneBook.add("Вова", "863 212 1102");
phoneBook.add("Леха", "863 243 1111");
phoneBook.add("Жека", "863 240 2704");
phoneBook.add("Витя", "863 248 2222");

System.out.println(phoneBook);
System.out.println(phoneBook.get("Вова"));

// --------------------------
}
}
65 changes: 65 additions & 0 deletions lesson_4/swing/MyWindow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package lesson_4.swing;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MyWindow extends JFrame {

public MyWindow() {
setTitle("MyWindows");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setBounds(500, 300, 500, 400);
setLayout(new GridLayout(2, 1));

// textarea ------------------------------------------------
JTextArea textArea = new JTextArea();
JScrollPane scrollPane = new JScrollPane(textArea);
textArea.append("Здесь будет отображаться вводимый текст \n");
add(scrollPane);
textArea.setEditable(false);
//-----------------------------------------------------------

// textfield-------------------------------------------------
JPanel text = new JPanel();

JTextField textField = new JTextField("введите текст");
textField.setPreferredSize(new Dimension(200, 30));
text.add(textField);

textField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (textField.getText().equals("")) {
textArea.append("Вы ввели пустой текст" + "\n");
} else {
textArea.append(textField.getText() + "\n");
textField.setText("");
textField.grabFocus();
}
}
});

// button ----------------------------------------------------

JButton button = new JButton("Отправить");
button.setPreferredSize(new Dimension(100, 30));
text.add(button);

button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (textField.getText().equals("")) {
textArea.append("Вы ввели пустой текст" + "\n");
} else {
textArea.append(textField.getText() + "\n");
textField.setText("");
}
}
});
//-----------------------------------------------------------
add(text);
setVisible(true);

}
}
15 changes: 15 additions & 0 deletions lesson_4/swing/main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package lesson_4.swing;



public class main {
public static void main(String[] args) {

new MyWindow();

}


}