0% found this document useful (0 votes)
7 views4 pages

Chap 6 Work

java program

Uploaded by

jikitacwb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Chap 6 Work

java program

Uploaded by

jikitacwb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

public class MyClass {

private int x;

private double y;

// myclass

public MyClass(int a, double b) {

x = a;

y = b;

public class TwoValues {

private int x, y;

// no parameters

public TwoValues() {

x = 0;

y = 0;

// param

public TwoValues(int a, int b) {

x = a;

y = b;

}
2

public class Pet {

// attrib

private String name;

private String animal;

private int age;

// fields analiszew

public Pet(String name, String animal, int age) {

this.name = name;

this.animal = animal;

this.age = age;

// name

public void setName(String name) {

this.name = name;

// s animal

public void setAnimal(String animal) {

this.animal = animal;

// s age
public void setAge(int age) {

this.age = age;

// name

public String getName() {

return this.name;

// animal

public String getAnimal() {

return this.animal;

// age

public int getAge() {

return this.age;

import java.util.Scanner;
public class Main {

public static void main(String[] args) {

Scanner keyboard = new Scanner(System.in);

Person person = new Person();

System.out.print("Enter the name of the person: ");

String name = keyboard.nextLine();

person.setName(name);

// Close

keyboard.close();

You might also like