This commit is contained in:
kto765 2025-03-19 11:58:22 +03:00
parent 656cff2eb5
commit 72b99d2617
6 changed files with 128 additions and 25 deletions

9
.idea/clicker_java.iml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/clicker_java.iml" filepath="$PROJECT_DIR$/.idea/clicker_java.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -5,8 +5,12 @@
</component>
<component name="ChangeListManager">
<list default="true" id="9a578395-edbe-4cfc-8f32-d73c18cae504" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/clicker_java.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/src/main/java/com/example/clicker/click.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/example/clicker/MainActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/example/clicker/MainActivity.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -41,9 +45,10 @@
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"android.gradle.sync.needed": "true",
"git-widget-placeholder": "master",
"git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/User/Desktop/clicker_java",
"settings.editor.selected.configurable": "reference.settingsdialog.project.gradle"
}
}]]></component>

View File

@ -1,39 +1,43 @@
package com.example.clicker;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextClock;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class MainActivity extends AppCompatActivity {
TextView mainText;
Button mainBtn;
private long score = 0;
Button drop_btn, minus_btn;
ImageView mainBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
mainText = (TextView) findViewById(R.id.mainText);
mainBtn = (Button) findViewById(R.id.button);
View.OnClickListener clickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
score ++;
String s = "Кликов: " + score;
mainText.setText(s.toCharArray(),0, s.length());
}
};
mainText = findViewById(R.id.mainText);
mainBtn = findViewById(R.id.main_btn);
drop_btn = findViewById(R.id.drop_btn);
minus_btn = findViewById(R.id.minus_btn);
Click clickListener = new Click(mainText);
mainBtn.setOnClickListener(clickListener);
drop_btn.setOnClickListener(clickListener);
minus_btn.setOnClickListener(clickListener);
}
}
}

View File

@ -0,0 +1,71 @@
package com.example.clicker;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Click implements View.OnClickListener {
TextView mainText;
String letter;
long score = 0;
public Click(TextView mainTxt){
this.mainText=mainTxt;
}
String primer="";
@Override
public void onClick(View v) {
int id = v.getId();
if (id==R.id.main_btn)
{
score++;
if (score % 100 >= 11 && score % 100 <= 14) {
letter = " раз";
} else {
switch ((int) (score % 10)) {
case 1:
letter = " раз";
break;
case 2:
case 3:
case 4:
letter = " раза";
break;
default:
letter = " раз";
}
}
String s = "Кнопка нажата: " + score + letter;
mainText.setText(s);
}
else if (id==R.id.minus_btn){
score--;
if (score % 100 >= 11 && score % 100 <= 14) {
letter = " раз";
} else {
switch ((int) (score % 10)) {
case 1:
letter = " раз";
break;
case 2:
case 3:
case 4:
letter = " раза";
break;
default:
letter = " раз";
}
}
String s = "Кнопка нажата: " + score + letter;
mainText.setText(s);
}
else if (id==R.id.drop_btn){
score=0;
String s = "Кнопка нажата " + score + " раз";
mainText.setText(s);
}
}
}