Everything saved dissapeared why?

  • (2 Pages)
  • +
  • 1
  • 2

25 Replies - 567 Views - Last Post: 04 June 2019 - 10:41 AM Rate Topic: -----

#16 Realme   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 147
  • Joined: 22-May 19

Re: Everything saved dissapeared why?

Posted 03 June 2019 - 01:36 PM

Do you know if it is accessible to access "novellsamling= novellsamling"?

That is one of my constructors
Was This Post Helpful? 0
  • +
  • -

#17 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6962
  • View blog
  • Posts: 23,666
  • Joined: 05-May 12

Re: Everything saved dissapeared why?

Posted 03 June 2019 - 05:08 PM

Please show your actual code, not a hypothetical. If it works, then there you have it. If it doesn't work, what error message does the compiler show you?
Was This Post Helpful? 0
  • +
  • -

#18 Realme   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 147
  • Joined: 22-May 19

Re: Everything saved dissapeared why?

Posted 04 June 2019 - 06:10 AM

Hi,

I am finally done with my task, only thing remaining is that I cant escape the program by pressing ESC why?

THIS IS EXAMPLE NOT REAL CODE BUT ESC FUNCTION IS IN SAME POSSITION:

using System;
002
using System.Collections.Generic;
003
using System.Linq;
004
using System.Text;
005
using System.Threading.Tasks;
006
 
007
public class Bok : IEquatable<Bok>
008
{
009
    public Bok(string partName, string partTitel, string partRoman, int partId)
010
    {
011
        Serie = partName;
012
        Titel = partTitel;
013
        Roman = partRoman;
014
        Märke = partId;
015
    }
016
 
017
    public Bok()
018
    {
019
    }
020
 
021
    public string Serie { get; set; }
022
 
023
    public string Titel { get; set; }
024
 
025
    public string Roman { get; set; }
026
 
027
    public int Märke { get; set; }
028
 
029
    public override string ToString()
030
    {
031
        return "Författaren: " + Serie  + "  Titel: " + Titel + " Boktyp: " + Roman +"    Utgivningsår:  " + Märke;
032
    }
033
    public override bool Equals(object obj)
034
    {
035
        if (obj == null) return false;
036
        Bok objAsPart = obj as Bok;
037
        if (objAsPart == null) return false;
038
        else return Equals(objAsPart);
039
    }
040
    public override int GetHashCode()
041
    {
042
        return Märke;
043
    }
044
    public bool Equals(Bok other)
045
    {
046
        if (other == null) return false;
047
        return (this.Märke.Equals(other.Märke));
048
    }
049
    // Should also override == and != operators.
050
 
051
}
052
    public class Författare : Bok
053
{
054
    public string Roman;
055
    public Författare(string Serie, string Titel, string Roman, int Märke) :
056
        base(Serie, Titel, Roman, Märke)
057
 
058
    { Roman = "Roman"; }
059
}
060
 
061
public class Titel : Bok
062
{
063
    public string Tidskrift;
064
    public Titel(string Serie, string Titel,string Roman, int Märke) :
065
        base(Serie,Titel, Roman, Märke)
066
 
067
    { Tidskrift = "Tidskrift"; }
068
}
069
public class Utg : Bok
070
{
071
    public string Novellsamling;
072
    public Utg(string Serie, string Titel,string Roman, int Märke) :
073
        base(Serie, Titel, Roman, Märke)
074
 
075
    { Novellsamling = "Novellsamling"; }
076
}
077
public class Example
078
{
079
    public static void Main()
080
    {
081
        do
082
        {
083
            // Create a list of parts.
084
            List<Bok> parts = new List<Bok>();
085
            Console.WriteLine("Välkommen");
086
            Console.WriteLine("[1] Registrera bok");
087
            Console.WriteLine("[2] Visa böcker");
088
            Console.WriteLine("[ESC] Avsluta");
089
            string Read = Console.ReadLine();
090
            Int32.TryParse(Read, out int P);
091
            switch (P)
092
            {
093
                case 1:
094
                    Författare Författaren = new Författare("Skriv in författaren: ", "Författaren är: ", "Boktypen är: ", 150);
095
                    Titel Titeln = new Titel("Skriv in Titel", "Titeln är: ", "QQ", 150);
096
 
097
                    // Add parts to the list.
098
                    Console.WriteLine("Vilken Boktyp är detta? ");
099
                    Console.WriteLine("[1] Roman");
100
                    Console.WriteLine("[2] Tidskeift");
101
                    Console.WriteLine("[3] Novellsamling");
102
 
103
                    string reader = Console.ReadLine();
104
                    Int32.TryParse(reader, out int W);
105
 
106
                    if (W == 1)
107
                    {
108
                        Console.WriteLine("ROMAN .....");
109
                        Console.WriteLine(Författaren.Serie);
110
                        Console.WriteLine(Titeln.Serie);
111
                        parts.Add(new Bok() { Serie = Console.ReadLine(), Titel = Console.ReadLine(), Roman = "Roman ", Märke = 1234 });
112
                    }
113
                    // Write out the parts in the list. This will call the overridden ToString method
114
                    // in the Part class.
115
                    //Console.WriteLine();
116
                    foreach (Bok aPart in parts)
117
                    {
118
                        Console.WriteLine(aPart);
119
                    }
120
 
121
                    break;
122
                case 2:
123
                    foreach (Bok aPart in parts)
124
                    {
125
                        Console.WriteLine(aPart);
126
                    }
127
                    break;
128
            } 
129
        }
130
        while (Console.ReadKey().Key != ConsoleKey.Escape);
131
    }
132
}

Was This Post Helpful? -2
  • +
  • -

#19 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15106
  • View blog
  • Posts: 60,394
  • Joined: 12-June 08

Re: Everything saved dissapeared why?

Posted 04 June 2019 - 06:47 AM

I would suggest posting your current code.
Was This Post Helpful? 0
  • +
  • -

#20 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6798
  • View blog
  • Posts: 28,091
  • Joined: 12-December 12

Re: Everything saved dissapeared why?

Posted 04 June 2019 - 06:49 AM

OP I have already stated more than once that you should post real code, and explained the reasoning for this.
Was This Post Helpful? 0
  • +
  • -

#21 Realme   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 147
  • Joined: 22-May 19

Re: Everything saved dissapeared why?

Posted 04 June 2019 - 06:52 AM

Andrew, I am afraid it will be classified as "copied code" and that I want to avoid as I will send this code to teacher
Was This Post Helpful? -1
  • +
  • -

#22 DarenR   User is offline

  • D.I.C Lover

Reputation: 616
  • View blog
  • Posts: 4,090
  • Joined: 12-January 10

Re: Everything saved dissapeared why?

Posted 04 June 2019 - 08:47 AM

nah -- the teacher should know people use forums for help
Was This Post Helpful? 1
  • +
  • -

#23 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6962
  • View blog
  • Posts: 23,666
  • Joined: 05-May 12

Re: Everything saved dissapeared why?

Posted 04 June 2019 - 10:37 AM

Furthermore, assuming that your profile picture is real, you can go to your schools Academic Honesty Board and be able to prove that the code that you supposedly plagiarized is your own code that you posted on the tho forum.

Anyway to answer your question why pressing Escape doesn't work is because you are using Console.ReadLine(). You'll have to write your own ReadLine() that understands the Escape key and returns a flag or throws an exception if the Escape key is pressed.
Was This Post Helpful? 0
  • +
  • -

#24 Realme   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 147
  • Joined: 22-May 19

Re: Everything saved dissapeared why?

Posted 04 June 2019 - 10:38 AM

Skydiver, yes that is true but that is just some unnecessary work to do
Was This Post Helpful? 0
  • +
  • -

#25 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6962
  • View blog
  • Posts: 23,666
  • Joined: 05-May 12

Re: Everything saved dissapeared why?

Posted 04 June 2019 - 10:40 AM

So it's better to not pay taxes because it is unnecessary work to do. Just pay all the back taxes later if/when they catch you. Better to ask for forgiveness than permission and all that jazz.
Was This Post Helpful? 0
  • +
  • -

#26 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6794
  • View blog
  • Posts: 31,346
  • Joined: 10-May 07

Re: Everything saved dissapeared why?

Posted 04 June 2019 - 10:41 AM

Unnecessary like pasting 'example' code & asking others to connect the dots?

Closing the topic, If your school doesn't allow outside help, then don't get outside help.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2