MATKAPRIZA
80+
- Katılım
- 25 Mart 2020
- Mesajlar
- 251
- Reaksiyon skoru
- 75
package pencil_case;
public class Pencil_Case {
public String Color;
public int Capacity = 5;
public int CurrentAmount = 0;
public boolean Add(){
if (CurrentAmount+1<=Capacity){
CurrentAmount++;
return true;
{
else
System.out.println("Pencilcase is Full");
return false;
}
public boolean Add(int amount) {
if (CurrentAmount + amount<=Capacity) {
CurrentAmount+=amount;
return true;
{
else
System.out.println("Pencilcase is Full");
return false;
}
public static void main(String[] args) {
Pencil_Case pc = new Pencil_Case();
pc.Color = "red";
pc.Add();
pc.Add();
pc.Add();
pc.Add();
pc.Add(3);
System.out.println("pc.CurrentAmount");
}
}
public class Pencil_Case {
public String Color;
public int Capacity = 5;
public int CurrentAmount = 0;
public boolean Add(){
if (CurrentAmount+1<=Capacity){
CurrentAmount++;
return true;
{
else
System.out.println("Pencilcase is Full");
return false;
}
public boolean Add(int amount) {
if (CurrentAmount + amount<=Capacity) {
CurrentAmount+=amount;
return true;
{
else
System.out.println("Pencilcase is Full");
return false;
}
public static void main(String[] args) {
Pencil_Case pc = new Pencil_Case();
pc.Color = "red";
pc.Add();
pc.Add();
pc.Add();
pc.Add();
pc.Add(3);
System.out.println("pc.CurrentAmount");
}
}