当前位置: 代码迷 >> J2SE >> 身在瑞典求救!很基础的有关问题,有关linux平台上用java做一个C/S系统
  详细解决方案

身在瑞典求救!很基础的有关问题,有关linux平台上用java做一个C/S系统

热度:114   发布时间:2016-04-24 17:33:40.0
身在瑞典求救!很基础的问题,有关linux平台上用java做一个C/S系统
跑到这里来交流,以前在上海学的是MIS,然后在这边选了门internet   technology,觉得无从下手阿!有一个最关键的实验是:
Design   and   implement   a   server   application   which   acts   as   an   Internet   bank,   i.e.   keeps   track   of   bank   accounts   and   allows   clients   to   connect   over   the   Internet   and   make   deposits   and   withdrawals   from   any   of   the   bank   accounts.   Also   implement   the   client   application.   Use   any   port   number   available   for   general   use,   i.e.   in   the   range   50000   through   65535.
简单来说就是用Java做一个C/S结构的“银行”系统,只要能取钱存钱就行。
然后还有以下要求:
1.   The   server   and   client   should   be   written   in   Java1   and   should   run   under   Linux.   Linux   computers   are   available   in   the   course   laboratory.   Coding   may   of   course   be   carried   out   on   any   computer   platform   of   your   choice.
2.   The   applications   should   communicate   through   TCP.
3.   The   server   must   be   able   to   handle   several   clients   simultaneously.   In   Java,   this   is   easiest   done   by   making   the   server   multithreaded.
4.   For   simplicity,   the   server   need   only   keep   track   of   ten   (10)   bank   accounts,   numbered   0   through   9.
5.   The   amount   of   money   (balance,   amount   withdrawn/deposited)   should   be   of   type   integer.
6.   The   server   should   register   in   the   bank   account   record   the   IP   address   of   the   host   that   made   the   last   transaction.   These   IP   addresses   should   be   printed   by   the   server   on   screen   along   with   the   account   number   and   account   balance   after   each   transaction.
7.   You   must   make   sure   that   several   clients,   each   corresponding   to   a   different   server   thread,   cannot   update   the   same   account   simultaneously.   In   Java,   this   can   be   done   easily   by   using   the   synchronized   keyword.
简单来说就是必须是tcp通信,多用户可以同时处理,等等。
问题是本人没有学过java,所以无从下手阿!google了相关内容,但是都是一大堆材料,抓不住核心。在这里提这个问题肯定很幼稚了,但是希望哪一位能给一些一针见血的提示,或是哪位有类似的范例。我在这里多谢了!!!

------解决方案--------------------
瑞典理工学院计算机水平众所周知很高,
你来这里问,还真不如找个当地的学生帮你解决.
而且他们他们代码的效率通常很高!!!
------解决方案--------------------
没学过 Java?那就真的郁闷了。慢慢学吧,希望你有的是时间。
------解决方案--------------------
事务处理的例子。

设置两个数据库。

BankA
BankB

两个数据库都具有各自的表“账务”:

3 编号 int 4 0 主键
0 姓名 varchar 50 1
0 金额 money 8 1


二、无事务的情况

import java.awt.*;
import .swing.*;

import java.io.*;
import java.sqljava.awt.event.*;
  相关解决方案