Skip to content

Commit aa9ccb4

Browse files
committed
Added a new tasks to level 19 (lesson 03 - home 01).
1 parent a76a19e commit aa9ccb4

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.javarush.test.level19.lesson03.task01;
2+
3+
/* TableAdapter
4+
Измените класс TableAdapter так, чтобы он адаптировал ATable к BTable.
5+
Метод getHeaderText должен возвращать такую строку "[username] : tablename".
6+
Пример, "[Amigo] : DashboardTable"
7+
*/
8+
9+
public class Solution
10+
{
11+
public static void main(String[] args)
12+
{
13+
ATable aTable = new ATable()
14+
{
15+
@Override
16+
public String getCurrentUserName()
17+
{
18+
return "Amigo";
19+
}
20+
21+
@Override
22+
public String getTableName()
23+
{
24+
return "DashboardTable";
25+
}
26+
};
27+
28+
BTable table = new TableAdapter(aTable);
29+
System.out.println(table.getHeaderText());
30+
}
31+
32+
public static class TableAdapter implements BTable
33+
{
34+
ATable table;
35+
36+
public TableAdapter(ATable table)
37+
{
38+
this.table = table;
39+
}
40+
41+
@Override
42+
public String getHeaderText()
43+
{
44+
return "[" + this.table.getCurrentUserName() + "] : " + this.table.getTableName();
45+
}
46+
}
47+
48+
public interface ATable
49+
{
50+
String getCurrentUserName();
51+
52+
String getTableName();
53+
}
54+
55+
public interface BTable
56+
{
57+
String getHeaderText();
58+
}
59+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy