Skip to content

Commit 84e10f1

Browse files
committed
lab 3-4
1 parent 86f0840 commit 84e10f1

File tree

10 files changed

+386
-12
lines changed

10 files changed

+386
-12
lines changed

src/ru/shureck/java2020/Kvort.java

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package ru.shureck.java2020.Kvort;
2+
3+
import java.util.Scanner;
4+
5+
public class Main {
6+
public static void main(String[] args) {
7+
int proc,num=0;
8+
int counter=0, proc_count=0;
9+
Scanner scanner = new Scanner(System.in);
10+
num = scanner.nextInt();
11+
proc = num;
12+
if(num == 1){
13+
System.out.println(1);
14+
}
15+
else {
16+
if(num % 5 == 2) proc_count -= 1;
17+
while (true) {
18+
if (proc - 5 >= 0) {
19+
proc_count += 3;
20+
proc -= 5;
21+
}
22+
else {
23+
if (proc - 3 >= 0) {
24+
proc_count += 2;
25+
proc -= 3;
26+
}
27+
else {
28+
if (proc - 1 >= 0) {
29+
proc_count += 1;
30+
proc -= 1;
31+
}
32+
else {
33+
break;
34+
}
35+
}
36+
}
37+
}
38+
System.out.println(proc_count);
39+
}
40+
}
41+
}

src/ru/shureck/java2020/Lab1.java renamed to src/ru/shureck/java2020/Lab1/Lab1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ru.shureck.java2020;
1+
package ru.shureck.java2020.Lab1;
22

33
import java.util.ArrayList;
44
import java.util.Collections;

src/ru/shureck/java2020/Lab2.java renamed to src/ru/shureck/java2020/Lab2/Lab2.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
package ru.shureck.java2020;
1+
package ru.shureck.java2020.Lab2;
22

3-
import java.util.ArrayList;
43
import java.util.Arrays;
54
import java.util.Scanner;
65

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package ru.shureck.java2020.Lab3;
2+
3+
public class Book {
4+
private String author;
5+
private String name;
6+
private int year;
7+
private int pages;
8+
9+
public Book(String author, String name, int year, int pages) {
10+
this.author = author;
11+
this.name = name;
12+
this.year = year;
13+
this.pages = pages;
14+
}
15+
16+
public String getAuthor() {
17+
return author;
18+
}
19+
20+
public String getName() {
21+
return name;
22+
}
23+
24+
public int getYear() {
25+
return year;
26+
}
27+
28+
public int getPages() {
29+
return pages;
30+
}
31+
32+
public void setAuthor(String author) {
33+
this.author = author;
34+
}
35+
36+
public void setName(String name) {
37+
this.name = name;
38+
}
39+
40+
public void setYear(int year) {
41+
this.year = year;
42+
}
43+
44+
public void setPages(int pages) {
45+
this.pages = pages;
46+
}
47+
48+
@Override
49+
public String toString() {
50+
return "Book{" +
51+
"author='" + author + '\'' +
52+
", name='" + name + '\'' +
53+
", year=" + year +
54+
", pages=" + pages +
55+
'}';
56+
}
57+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package ru.shureck.java2020.Lab3;
2+
3+
public class Circle {
4+
private float radius;
5+
private String color;
6+
private boolean isEmpty;
7+
8+
public Circle(float rad, String col, boolean emt){
9+
radius = rad;
10+
color = col;
11+
isEmpty = emt;
12+
}
13+
14+
public float getP(){
15+
return (float) (2*Math.PI*radius);
16+
}
17+
18+
public float getS(){
19+
return (float) Math.PI*radius*radius;
20+
}
21+
22+
public float getRadius() {
23+
return radius;
24+
}
25+
26+
public String getColor() {
27+
return color;
28+
}
29+
30+
public boolean isEmpty() {
31+
return isEmpty;
32+
}
33+
34+
public void setRadius(float radius) {
35+
this.radius = radius;
36+
}
37+
38+
public void setColor(String color) {
39+
this.color = color;
40+
}
41+
42+
public void setEmpty(boolean empty) {
43+
this.isEmpty = empty;
44+
}
45+
46+
@Override
47+
public String toString() {
48+
return "Circle{" +
49+
"radius=" + radius +
50+
", color='" + color + '\'' +
51+
", isEmpty=" + isEmpty +
52+
", P=" + getP() +
53+
", S=" + getS() +
54+
'}';
55+
}
56+
}
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
package ru.shureck.java2020.Lab3;
2+
3+
class Head{
4+
private float brainVolume;
5+
private String eyeColor;
6+
private boolean isBald;
7+
8+
public Head(float brainVolume, String eyeColor, boolean isBald) {
9+
this.brainVolume = brainVolume;
10+
this.eyeColor = eyeColor;
11+
this.isBald = isBald;
12+
}
13+
14+
public float getBrainVolume() {
15+
return brainVolume;
16+
}
17+
18+
public String getEyeColor() {
19+
return eyeColor;
20+
}
21+
22+
public boolean isBald() {
23+
return isBald;
24+
}
25+
26+
public void setBrainVolume(float brainVolume) {
27+
this.brainVolume = brainVolume;
28+
}
29+
30+
public void setEyeColor(String eyeColor) {
31+
this.eyeColor = eyeColor;
32+
}
33+
34+
public void setBald(boolean bald) {
35+
isBald = bald;
36+
}
37+
}
38+
class Legs{
39+
private float length;
40+
private float footSize;
41+
42+
public Legs(float length, float footSize) {
43+
this.length = length;
44+
this.footSize = footSize;
45+
}
46+
47+
public float getLength() {
48+
return length;
49+
}
50+
51+
public float getFootSize() {
52+
return footSize;
53+
}
54+
55+
public void setLength(float length) {
56+
this.length = length;
57+
}
58+
59+
public void setFootSize(float footSize) {
60+
this.footSize = footSize;
61+
}
62+
}
63+
class Hands{
64+
private float length;
65+
66+
public Hands(float length) {
67+
this.length = length;
68+
}
69+
70+
public float getLength() {
71+
return length;
72+
}
73+
74+
public void setLength(float length) {
75+
this.length = length;
76+
}
77+
}
78+
class Body{
79+
private boolean isFat;
80+
81+
public Body(boolean isFat) {
82+
this.isFat = isFat;
83+
}
84+
85+
public boolean isFat() {
86+
return isFat;
87+
}
88+
89+
public void setFat(boolean fat) {
90+
isFat = fat;
91+
}
92+
}
93+
94+
public class Human {
95+
96+
private Head head;
97+
private Legs legs;
98+
private Hands hands;
99+
private Body body;
100+
private String name;
101+
private int age;
102+
private float weight;
103+
104+
public Human(Head head, Legs legs, Hands hands, Body body, String name, int age, float weight) {
105+
this.head = head;
106+
this.legs = legs;
107+
this.hands = hands;
108+
this.body = body;
109+
this.name = name;
110+
this.age = age;
111+
this.weight = weight;
112+
}
113+
114+
public String getName() {
115+
return name;
116+
}
117+
118+
public int getAge() {
119+
return age;
120+
}
121+
122+
public float getWeight() {
123+
return weight;
124+
}
125+
126+
public void setName(String name) {
127+
this.name = name;
128+
}
129+
130+
public void setAge(int age) {
131+
this.age = age;
132+
}
133+
134+
public void setWeight(float weight) {
135+
this.weight = weight;
136+
}
137+
138+
public Head getHead() {
139+
return head;
140+
}
141+
142+
public Legs getLegs() {
143+
return legs;
144+
}
145+
146+
public Hands getHands() {
147+
return hands;
148+
}
149+
150+
public Body getBody() {
151+
return body;
152+
}
153+
154+
public void setHead(Head head) {
155+
this.head = head;
156+
}
157+
158+
public void setLegs(Legs legs) {
159+
this.legs = legs;
160+
}
161+
162+
public void setHands(Hands hands) {
163+
this.hands = hands;
164+
}
165+
166+
public void setBody(Body body) {
167+
this.body = body;
168+
}
169+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package ru.shureck.java2020.Lab3;
2+
3+
public class Lab3 {
4+
public static void main(String[] args) {
5+
6+
Human human = new Human(new Head(1240,"green",false),
7+
new Legs(90, 45), new Hands(61), new Body(false), "Sam", 19, 68);
8+
9+
Circle circle = new Circle(20,"red",false);
10+
11+
Book book = new Book("Брюс Эккель", "Философия Java", 2009, 450);
12+
13+
System.out.println(circle);
14+
System.out.println(book);
15+
}
16+
}

0 commit comments

Comments
 (0)