我的程序的目标是允许用户输入最多100个人名和100个汽车名。然后用户可以注册"通过让这些人指向那辆车,向他/她希望的人们开车。
我想我的第一个问题是,获取用户输入字符串并将其放入数组的最佳方式是什么?那么使用寄存器功能的最佳方法是什么,以便用户指定的人指向特定的汽车?任何帮助非常感谢! (此作业不允许使用向量)
class Person{
public:
Person();
void Register(Car& theirCar);
private:
string personName;
};
class Car{
public:
Car();
private:
string carName;
};
Person::Person()
{
//Set to null
}
Car::Car()
{
//Set to null
}
int main()
{
Car cars[101];
Person persons[101];
char selection;
while(1)
{
cout << "Currently looking at:\n";
cout << "Person: " << endl;
cout << "In car: " << endl;
cout << "Do you want to (p) make a new person, (c) make a new car,\n";
cout << "(f) find a person, (r) register a person to a car, or (q) quit\n";
cin >> selection;
if(selection == 'p')
{
cout << "What is this person's name?\n";
}
if(selection == 'c')
{
cout << "What is this car's name?\n";
}
if(selection == 'f')
{
cout << "Which person do you want to find?\n";
}
if(selection == 'r')
{
cout << "Which car do you wish to register to this person?\n";
}
if(selection == 'q')
{
return(0);
}
}
}
&#13;
答案 0 :(得分:0)
这不是一个完整的答案,但根据评论中的讨论是一个开始的地方。它试图提供一个相对最小(但完整)的例子,说明对象实例如何存储指向另一个对象的指针。
public class KeystoreLoad {
public static void main(String[] args) throws Exception {
char[] password = "nokia123".toCharArray();
String alias = "/btsmed-1/certh-1/necert-1";
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(null, null);
FileInputStream fIn = new FileInputStream("d://keystore/keystore.jks");
keystore.load(fIn, password);
X509Certificate[] certs1 = (X509Certificate[]) keystore.getCertificateChain(alias);
System.out.println(Arrays.toString(certs1));
}
}