Graderpractice for programmers

Back to 254275 OOP Lab 5-10

Q8. Is your Castle ???

Problem

Castles have owner. Add a method named is IsyouCastle that returns true if the correct name Castle owner

  • Vachirapon Tosawat owns the java
  • Piyachok Seangbuddee owns the the python
  • Nanthaphong Khongyut owns the the kotlin
  • Thadaphong Kesornprom owns the the swift
  • Puwanasul Klanhun owns the ruby
  • Panuphun Injan owns the javascpit
public static void main(String[] args)
{
      Scanner sc = new Scanner(System.in);
        int castle = Integer.parseInt(sc.nextLine());
        int principality = Integer.parseInt(sc.nextLine());
        String owner = sc.nextLine().toLowerCase();
        String name = sc.nextLine().toLowerCase();
        Palace p = new Palace(castle,principality,name,owner);
        if (p.isyourCastle()==true)
        {
          System.out.println(p.getOwner()+" is the owner of the "+p.getName()+" castle.");
        }
        else
        {
          System.out.println(p.getOwner()+" isn't the owner of the "+p.getName()+" castle.");
        }
 }

Examples

Input

8
10
Vachirapon Tosawat
java

Output

Vachirapon Tosawat is the owner of the java castle.

Input

12
15
Piyachok Seangbuddee
python

Output

Piyachok Seangbuddee is the owner of the python castle.

Input

9
12
Nanthaphong Khongyut
ruby

Output

Nanthaphong Khongyut isn't the owner of the ruby castle.

Submit your solution

java