由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Java/C++ 的牛人们给看看这个Interview的Home test (急)
相关主题
static initialization dependency c++ (转载)请问我写的这个代码哪可以改进一下
问个C++问题singleton pattern problem
一个电面max sub vector sum 问题
How to convert string to string array (or vector) (转载)问一道题(8)
问个C++语法的问题帮我看一下5行代码
T家电面面经并且不解为何被秒拒Riverbed 面经
这种backtracking的问题怎么算时间复杂度?比如palindrom patitioning.谁能猜猜,这是个什么 algorithm?
问一个C++ set和unordered_set iterator的问题问一道C# interview testing quesiton
相关话题的讨论汇总
话题: string话题: public话题: person话题: result
进入JobHunting版参与讨论
1 (共1页)
b*******y
发帖数: 35
1
我多年不用Java了,不太灵光了。对熟悉的牛们,应该不难。
Suppose that your boss walks in one day and drops the following code on your
desk. Your
asked to spend an hour or two and improve the quality of the code. What
would you suggest
to improve this? Each suggested improvement, comment, or observation can get
you extra
credit. If you have any questions, please make note of them as part of your
feedback!
Creativity is a plus.
Don't write any code! Just put your commentary inline, kind of a stream-of-
concisousness
approach.
class Person
{
public static Vector getPeople()
{
return people;
}
protected static Vector people = new Vector();
private String fName = "";
private String fAddress = "";
public Person (String name, String address)
{
if (name.length() == 0)
throw new IllegalArgumentException ("Person needs a non-blank name");
if (address.length() == 0)
throw new IllegalArgumentException ("Person needs a non-blank
address");
fName = name;
fAddress = address;
people.add (this);
initialize ();
}
protected void initialize ()
{
...;
}
public void store ()
{
try
{
String data = stringify ();
...;
}
catch (Exception e)
{
e.printStackTrace();
}
}
private String stringify ()
{
String result = "";
result += name;
// String[] items = address.split ("\s+", -2);
// for (int i = 0; i< items.length; i++)
// {
// result += "|";
// result += items[i];
// }
result += "|";
result += address;
return result;
}
}
class Customer extends Person
{
public static int BasicAcct = 0;
public static int PlusAcct = 1;
public static int ExecAcct = 2;
private long _accountid = 0;
private int _accounttype = 0;
public Customer (String name, String address)
{
super (name, address);
_accounttype = BasicAcct;
_accountid = IDManager.getId ();
}
protected void initialize ()
{
super.initialize ();
_accounttype = PlusAcct;
}
public void putAccountType (int acct)
{
_accounttype = acct;
}
public long getAccountId ()
{
return _accountid;
}
}
l*****a
发帖数: 14598
2
什么厂啊?

your
get
your

【在 b*******y 的大作中提到】
: 我多年不用Java了,不太灵光了。对熟悉的牛们,应该不难。
: Suppose that your boss walks in one day and drops the following code on your
: desk. Your
: asked to spend an hour or two and improve the quality of the code. What
: would you suggest
: to improve this? Each suggested improvement, comment, or observation can get
: you extra
: credit. If you have any questions, please make note of them as part of your
: feedback!
: Creativity is a plus.

t**r
发帖数: 3428
3
问题太多了。呵呵。
一句话评语:shit code. fire the author and rewrite it
1 (共1页)
进入JobHunting版参与讨论
相关主题
问一道C# interview testing quesiton问个C++语法的问题
问个外循环和内问题T家电面面经并且不解为何被秒拒
关于java synchronized statement和static method or variable这种backtracking的问题怎么算时间复杂度?比如palindrom patitioning.
那位大牛做过这道题问一个C++ set和unordered_set iterator的问题
static initialization dependency c++ (转载)请问我写的这个代码哪可以改进一下
问个C++问题singleton pattern problem
一个电面max sub vector sum 问题
How to convert string to string array (or vector) (转载)问一道题(8)
相关话题的讨论汇总
话题: string话题: public话题: person话题: result