Selaa lähdekoodia

{Resolve merge}

Khalil Saboor 6 vuotta sitten
vanhempi
commit
1c07b9f7b7
1 muutettua tiedostoa jossa 0 lisäystä ja 133 poistoa
  1. 0
    133
      Labch2.rtf

+ 0
- 133
Labch2.rtf Näytä tiedosto

@@ -1,133 +0,0 @@
1
-{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf400
2
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
3
-{\colortbl;\red255\green255\blue255;}
4
-{\*\expandedcolortbl;;}
5
-\margl1440\margr1440\vieww12800\viewh8400\viewkind0
6
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
7
-
8
-\f0\fs24 \cf0 2.1 ##################\
9
-# The BlueJ Line\
10
-# Ticket\
11
-# 500 cents.\
12
-##################\
13
-\
14
-2.2   500 cents\
15
-\
16
-2.3.  ##################\
17
-# The BlueJ Line\
18
-# Ticket\
19
-# 500 cents.\
20
-##################\
21
-\
22
-##################\
23
-# The BlueJ Line\
24
-# Ticket\
25
-# 500 cents.\
26
-##################\
27
-\
28
-##################\
29
-# The BlueJ Line\
30
-# Ticket\
31
-# 500 cents.\
32
-##################\
33
-\
34
-\
35
-\
36
-2.5 the printed value is different\
37
-\
38
-\
39
-2.6 \
40
-\
41
-\{\
42
-Methods\
43
-Const\
44
-Variables \
45
-\}\
46
-\
47
-2.7 Yes this will cause an error\
48
-\
49
-2.8 It is possible no syntactical error. \
50
-\
51
-2.9    private int price;\
52
-   \
53
-    private int balance;\
54
-    \
55
-    private int total;\
56
-\
57
-        const - \
58
-        price \
59
-        balance\
60
-        total \
61
-\
62
-	TicketMachine\
63
-	getPrice\
64
-	balance\
65
-	insertMoney\
66
-	printTicket\
67
-	\
68
-\
69
-2.10  price = ticketCost;\
70
-        balance = 0;\
71
-        total = 0;\
72
-	the prices seems to be set \
73
-\
74
-\pard\pardeftab720\partightenfactor0
75
-\cf0 Exercise 2.11 What do you think is the type of each of the following fields?\
76
-private int count;   	INT\
77
-private Student representative; 	STRING\
78
-private Server host;	STRING\
79
-\
80
-Exercise 2.12 What are the names of the following fields?\
81
-private boolean alive;\
82
-private Person tutor;\
83
-private Game game;\
84
-\
85
-Exercise 2.13 In the following field declaration from the TicketMachine class\
86
-private int price;\
87
-does it matter which order the three words appear in? Edit the TicketMachine class to\
88
-try different orderings. After each change, close the editor. Does the appearance of the\
89
-class diagram after each change give you a clue as to whether or not other orderings are\
90
-possible? Check by pressing the Compile button to see if there is an error message.\
91
-Make sure that you reinstate the original version after your experiments!\
92
-\
93
-Exercise 2.14 Is it always necessary to have a semicolon at the end of a field declaration?\
94
-Once again, experiment via the editor. The rule you will learn here is an\
95
-important one, so be sure to remember it. \
96
-\
97
-	YES, the java lang read needs a semicolon to read statements\
98
-\
99
-Exercise 2.15 Write in full the declaration for a field of type int whose name is\
100
-status.\
101
- \
102
-\
103
-\
104
-Exercise 2.16 To what class does the following constructor belong?\
105
-public Student(String name)\
106
-\
107
-Exercise 2.17 How many parameters does the following constructor have and\
108
-what are their types?\
109
-public Book(String title, double price)\
110
-\
111
-2 params, String & double\
112
-\
113
-Exercise 2.18 Can you guess what types some of the Book class\'92s fields might\
114
-be? Can you assume anything about the names of its fields?\
115
-\
116
-Exercise 2.19 Suppose that the class Pet has a field called name that is of type\
117
-String. Write an assignment statement in the body of the following constructor so\
118
-that the name field will be initialized with the value of the constructor\'92s parameter.\
119
-public Pet(String petsName)\
120
-\{\
121
-...\
122
-\}\
123
-Exercise 2.20 Challenge exercise What is wrong with the following version of the\
124
-constructor of TicketMachine?\
125
-public TicketMachine(int ticketCost)\
126
-\{\
127
-int price = ticketCost;\
128
-balance = 0;\
129
-total = 0;\
130
-\}\
131
-TICKETCOST IS ALREADY ASSIGN AS AN INT.\
132
-\
133
-}