NameUpdate
This commit is contained in:
16
MoreOnClasses/pom.xml
Normal file
16
MoreOnClasses/pom.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.oop</groupId>
|
||||
<artifactId>more_on_classes</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
12
MoreOnClasses/src/main/java/com/oop/Main.java
Normal file
12
MoreOnClasses/src/main/java/com/oop/Main.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.oop;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Scanner read = new Scanner(System.in);
|
||||
int a = read.nextInt();
|
||||
|
||||
Pupil pupil = new Pupil();
|
||||
pupil.setAge(a);
|
||||
}
|
||||
}
|
29
MoreOnClasses/src/main/java/com/oop/Pupil.java
Normal file
29
MoreOnClasses/src/main/java/com/oop/Pupil.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.oop;
|
||||
// You need a program to manage admissions for an art school. Pupils can be admitted to the school if they are over 6 years of age.
|
||||
// You're given a program which declares a Pupil class.
|
||||
// Task
|
||||
// Complete the setAge method of the Pupil class. If the value of parameter a is over 6, assign it to age attribute and output "Welcome".
|
||||
// Output "Sorry" otherwise.
|
||||
// Sample Input
|
||||
// 7
|
||||
// Sample Output
|
||||
// Welcome
|
||||
|
||||
|
||||
public class Pupil {
|
||||
private int age;
|
||||
|
||||
//complete setter method
|
||||
public void setAge(int a){
|
||||
if (a > 6) {
|
||||
age = a;
|
||||
System.out.println("Welcome");
|
||||
}else{
|
||||
System.out.println("Sorry");
|
||||
}
|
||||
}
|
||||
|
||||
public int getAge(){
|
||||
return age;
|
||||
}
|
||||
}
|
BIN
MoreOnClasses/target/classes/com/oop/Main.class
Normal file
BIN
MoreOnClasses/target/classes/com/oop/Main.class
Normal file
Binary file not shown.
BIN
MoreOnClasses/target/classes/com/oop/Pupil.class
Normal file
BIN
MoreOnClasses/target/classes/com/oop/Pupil.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user